def test_exif_date(self): sample = 'sample.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) d = im_md.get_date() self.assertEqual(d, datetime.datetime(2010, 2, 5, 23, 56, 24)) sample = 'sample-model-nikon1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) d = im_md.get_date() self.assertEqual(d, datetime.datetime(2011, 5, 21, 22, 19, 30))
def test_lens(self): sample = 'sample-model-nikon1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_lens_name(), '35mm F1.8 D G') sample = 'sample-model-nikon2.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_lens_name(), '70-200mm F2.8 D G') sample = 'sample-model-pentax1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_lens_name(), 'smc PENTAX-DA 18-55mm F3.5-5.6 AL WR')
def test_keywords(self): sample = 'sample-image-keywords.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_keywords(), set(['lazygal', 'Iptc.Application2.Keywords.lazygal', 'Xmp.MicrosoftPhoto.LastKeywordXMP.lazygal', 'Xmp.dc.subject.lazygal', 'Xmp.digiKam.TagsList.lazygal' #'Xmp.lr.hierarchicalSubject.lazygal' ]) )
def test_usercomment_empty_and_encoding(self): """ Exif.Photo.UserComment: charset="Ascii" Exif.Image.ImageDescription: unset Iptc.Application2.ObjectName: Jasper the Bear In this example, the IPTC tag should be chosen because the EXIF photo user comment should be considered empty. """ sample = 'sample-usercomment-empty-and-encoding.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_comment(), u'Jasper the Bear')
def test_authorship(self): sample = 'sample-author-badencoding.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_authorship(), u'\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd')
def test_focal_length(self): sample = 'sample-model-pentax1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_focal_length(), '18 mm (35 mm equivalent: 27 mm)')
def test_flash(self): sample = 'sample-model-pentax1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_flash(), 'Yes, auto')
def test_model(self): sample = 'sample-model-nikon1.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_camera_name(), 'NIKON D5000')
def test_usercomment_unicode_be(self): sample = 'sample-usercomment-unicode-mm.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_comment(), u'unicode test : éàê')
def test_usercomment_ascii(self): sample = 'sample-usercomment-ascii.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_comment(), u'deja vu')
def test_jpeg_comment_unicode(self): sample = 'sample-jpeg-comment-unicode.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_comment(), u'test jpeg comment éù')
def test_image_description(self): sample = 'sample-image-description.jpg' im_md = metadata.ImageInfoTags(self.get_sample_path(sample)) self.assertEqual(im_md.get_comment(), 'test ImageDescription')
def test_comment_none(self): im_md = metadata.ImageInfoTags(self.get_sample_path('sample.jpg')) self.assertEqual(im_md.get_comment(), '')