aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMark Lee <bzr@lazymalevolence.com>2010-02-09 11:17:41 -0800
committerMark Lee <bzr@lazymalevolence.com>2010-02-09 11:17:41 -0800
commit742ba51a3bf978de53f09865c2b50e7d555866aa (patch)
tree340bee363c1321f224b7462ec3737b4a5f2ec385 /test
parent7d4437dfcf57987252a881c858b3d7c3605c755e (diff)
downloadpyexiv2-742ba51a3bf978de53f09865c2b50e7d555866aa.tar.gz
Add an XMP metadata test.
Diffstat (limited to 'test')
-rw-r--r--test/ReadMetadataTestCase.py125
-rw-r--r--test/data/exiv2-bug540.jpgbin0 -> 10011 bytes
2 files changed, 124 insertions, 1 deletions
diff --git a/test/ReadMetadataTestCase.py b/test/ReadMetadataTestCase.py
index b99a221..358cf7c 100644
--- a/test/ReadMetadataTestCase.py
+++ b/test/ReadMetadataTestCase.py
@@ -66,6 +66,12 @@ class ReadMetadataTestCase(unittest.TestCase):
self.assertEqual(type(tag.values[0]), etype)
self.assertEqual(tag.values[0], evalue)
+ def assertCorrectFile(self, filename, md5sum):
+ """
+ Ensure that the filename and the MD5 checksum match up.
+ """
+ self.assert_(testutils.CheckFileSum(filename, md5sum))
+
def testReadMetadata(self):
"""
Perform various tests on reading the metadata contained in a file.
@@ -73,7 +79,7 @@ class ReadMetadataTestCase(unittest.TestCase):
# Check that the reference file is not corrupted
filename = os.path.join('data', 'smiley1.jpg')
md5sum = 'c066958457c685853293058f9bf129c1'
- self.assert_(testutils.CheckFileSum(filename, md5sum))
+ self.assertCorrectFile(filename, md5sum)
# Read the image metadata
image = pyexiv2.ImageMetadata(filename)
@@ -111,3 +117,120 @@ class ReadMetadataTestCase(unittest.TestCase):
self.assertEqual(image.iptc_keys, [tag[0] for tag in iptcTags])
for key, ktype, value in iptcTags:
self.checkIPTCTypeAndValue(image[key], ktype, value)
+
+ def testReadMetadataXMP(self):
+ filename = os.path.join('data', 'exiv2-bug540.jpg')
+ md5sum = '64d4b7eab1e78f1f6bfb3c966e99eef2'
+ self.assertCorrectFile(filename, md5sum)
+
+ # Read the image metadata
+ image = pyexiv2.ImageMetadata(filename)
+ image.read()
+
+ xmpTags = [('Xmp.dc.creator', 'seq ProperName', [u'Ian Britton']),
+ ('Xmp.dc.description', 'Lang Alt', {u'x-default': u'Communications'}),
+ ('Xmp.dc.rights', 'Lang Alt', {u'x-default': u'ian Britton - FreeFoto.com'}),
+ ('Xmp.dc.source', 'Text', u'FreeFoto.com'),
+ ('Xmp.dc.subject', 'bag Text', [u'Communications']),
+ ('Xmp.dc.title', 'Lang Alt', {u'x-default': u'Communications'}),
+ ('Xmp.exif.ApertureValue',
+ 'Rational',
+ pyexiv2.utils.Rational(8, 1)),
+ ('Xmp.exif.BrightnessValue',
+ 'Rational',
+ pyexiv2.utils.Rational(333, 1280)),
+ ('Xmp.exif.ColorSpace', 'Closed Choice of Integer', 1),
+ ('Xmp.exif.DateTimeOriginal',
+ 'Date',
+ datetime.datetime(2002, 7, 13, 15, 58, 28, tzinfo=pyexiv2.utils.FixedOffset())),
+ ('Xmp.exif.ExifVersion', 'Closed Choice of Text', u'0200'),
+ ('Xmp.exif.ExposureBiasValue',
+ 'Rational',
+ pyexiv2.utils.Rational(-13, 20)),
+ ('Xmp.exif.ExposureProgram', 'Closed Choice of Integer', 4),
+ ('Xmp.exif.FNumber',
+ 'Rational',
+ pyexiv2.utils.Rational(3, 5)),
+ ('Xmp.exif.FileSource', 'Closed Choice of Integer', 0),
+ ('Xmp.exif.FlashpixVersion', 'Closed Choice of Text', u'0100'),
+ ('Xmp.exif.FocalLength',
+ 'Rational',
+ pyexiv2.utils.Rational(0, 1)),
+ ('Xmp.exif.FocalPlaneResolutionUnit', 'Closed Choice of Integer', 2),
+ ('Xmp.exif.FocalPlaneXResolution',
+ 'Rational',
+ pyexiv2.utils.Rational(3085, 256)),
+ ('Xmp.exif.FocalPlaneYResolution',
+ 'Rational',
+ pyexiv2.utils.Rational(3085, 256)),
+ ('Xmp.exif.GPSLatitude',
+ 'GPSCoordinate',
+ pyexiv2.utils.GPSCoordinate.from_string('54,59.380000N')),
+ ('Xmp.exif.GPSLongitude',
+ 'GPSCoordinate',
+ pyexiv2.utils.GPSCoordinate.from_string('1,54.850000W')),
+ ('Xmp.exif.GPSMapDatum', 'Text', u'WGS84'),
+ ('Xmp.exif.GPSTimeStamp',
+ 'Date',
+ datetime.datetime(2002, 7, 13, 14, 58, 24, tzinfo=pyexiv2.utils.FixedOffset())),
+ ('Xmp.exif.GPSVersionID', 'Text', u'2.0.0.0'),
+ ('Xmp.exif.ISOSpeedRatings', 'seq Integer', [0]),
+ ('Xmp.exif.MeteringMode', 'Closed Choice of Integer', 5),
+ ('Xmp.exif.PixelXDimension', 'Integer', 2400),
+ ('Xmp.exif.PixelYDimension', 'Integer', 1600),
+ ('Xmp.exif.SceneType', 'Closed Choice of Integer', 0),
+ ('Xmp.exif.SensingMethod', 'Closed Choice of Integer', 2),
+ ('Xmp.exif.ShutterSpeedValue',
+ 'Rational',
+ pyexiv2.utils.Rational(30827, 3245)),
+ ('Xmp.pdf.Keywords', 'Text', u'Communications'),
+ ('Xmp.photoshop.AuthorsPosition', 'Text', u'Photographer'),
+ ('Xmp.photoshop.CaptionWriter', 'ProperName', u'Ian Britton'),
+ ('Xmp.photoshop.Category', 'Text', u'BUS'),
+ ('Xmp.photoshop.City', 'Text', u' '),
+ ('Xmp.photoshop.Country', 'Text', u'Ubited Kingdom'),
+ ('Xmp.photoshop.Credit', 'Text', u'Ian Britton'),
+ ('Xmp.photoshop.DateCreated', 'Date', datetime.date(2002, 6, 20)),
+ ('Xmp.photoshop.Headline', 'Text', u'Communications'),
+ ('Xmp.photoshop.State', 'Text', u' '),
+ ('Xmp.photoshop.SupplementalCategories', 'bag Text', [u'Communications']),
+ ('Xmp.photoshop.Urgency', 'Integer', 5),
+ ('Xmp.tiff.Artist', 'ProperName', u'Ian Britton'),
+ ('Xmp.tiff.BitsPerSample', 'seq Integer', [8]),
+ ('Xmp.tiff.Compression', 'Closed Choice of Integer', 6),
+ ('Xmp.tiff.Copyright',
+ 'Lang Alt',
+ {u'x-default': u'ian Britton - FreeFoto.com'}),
+ ('Xmp.tiff.ImageDescription', 'Lang Alt', {u'x-default': u'Communications'}),
+ ('Xmp.tiff.ImageLength', 'Integer', 400),
+ ('Xmp.tiff.ImageWidth', 'Integer', 600),
+ ('Xmp.tiff.Make', 'ProperName', u'FUJIFILM'),
+ ('Xmp.tiff.Model', 'ProperName', u'FinePixS1Pro'),
+ ('Xmp.tiff.Orientation', 'Closed Choice of Integer', 1),
+ ('Xmp.tiff.ResolutionUnit', 'Closed Choice of Integer', 2),
+ ('Xmp.tiff.Software', 'AgentName', u'Adobe Photoshop 7.0'),
+ ('Xmp.tiff.XResolution',
+ 'Rational',
+ pyexiv2.utils.Rational(300, 1)),
+ ('Xmp.tiff.YCbCrPositioning', 'Closed Choice of Integer', 2),
+ ('Xmp.tiff.YResolution',
+ 'Rational',
+ pyexiv2.utils.Rational(300, 1)),
+ ('Xmp.xmp.CreateDate',
+ 'Date',
+ datetime.datetime(2002, 7, 13, 15, 58, 28, tzinfo=pyexiv2.utils.FixedOffset())),
+ ('Xmp.xmp.ModifyDate',
+ 'Date',
+ datetime.datetime(2002, 7, 19, 13, 28, 10, tzinfo=pyexiv2.utils.FixedOffset())),
+ ('Xmp.xmpBJ.JobRef', 'bag Job', []),
+ ('Xmp.xmpBJ.JobRef[1]', '', ''),
+ ('Xmp.xmpBJ.JobRef[1]/stJob:name', '', 'Photographer'),
+ ('Xmp.xmpMM.DocumentID',
+ 'URI',
+ 'adobe:docid:photoshop:84d4dba8-9b11-11d6-895d-c4d063a70fb0'),
+ ('Xmp.xmpRights.Marked', 'Boolean', True),
+ ('Xmp.xmpRights.WebStatement', 'URL', 'www.freefoto.com')]
+ for key, xtype, value in xmpTags:
+ tag = image[key]
+ self.assertEqual(tag.type, xtype)
+ self.assertEqual(tag.value, value)
diff --git a/test/data/exiv2-bug540.jpg b/test/data/exiv2-bug540.jpg
new file mode 100644
index 0000000..62c0e56
--- /dev/null
+++ b/test/data/exiv2-bug540.jpg
Binary files differ