本文整理汇总了Python中elodie.media.photo.Photo.get_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.get_metadata方法的具体用法?Python Photo.get_metadata怎么用?Python Photo.get_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elodie.media.photo.Photo
的用法示例。
在下文中一共展示了Photo.get_metadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_location
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_location():
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
# Verify that original photo has different location info that what we
# will be setting and checking
assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude']
assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude']
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
示例2: test_set_utime_without_exif_date
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_utime_without_exif_date():
filesystem = FileSystem()
temporary_folder, folder = helper.create_working_folder()
origin = os.path.join(folder,'photo.jpg')
shutil.copyfile(helper.get_file('no-exif.jpg'), origin)
media_initial = Photo(origin)
metadata_initial = media_initial.get_metadata()
initial_stat = os.stat(origin)
initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
initial_checksum = helper.checksum(origin)
assert initial_time == time.mktime(metadata_initial['date_taken'])
filesystem.set_utime(media_initial)
final_stat = os.stat(origin)
final_checksum = helper.checksum(origin)
media_final = Photo(origin)
metadata_final = media_final.get_metadata()
shutil.rmtree(folder)
assert initial_time == final_stat.st_mtime
assert final_stat.st_mtime == time.mktime(metadata_final['date_taken']), (final_stat.st_mtime, time.mktime(metadata_final['date_taken']))
assert initial_checksum == final_checksum
示例3: test_update_time_on_photo
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_update_time_on_photo():
temporary_folder, folder = helper.create_working_folder()
temporary_folder_destination, folder_destination = helper.create_working_folder()
origin = "%s/plain.jpg" % folder
shutil.copyfile(helper.get_file("plain.jpg"), origin)
photo = Photo(origin)
metadata = photo.get_metadata()
reset_hash_db()
status = elodie.update_time(photo, origin, "2000-01-01 12:00:00")
restore_hash_db()
photo_processed = Photo(origin)
metadata_processed = photo_processed.get_metadata()
shutil.rmtree(folder)
shutil.rmtree(folder_destination)
assert status == True, status
assert metadata["date_taken"] != metadata_processed["date_taken"]
assert metadata_processed["date_taken"] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed[
"date_taken"
]
示例4: _test_photo_type_set
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def _test_photo_type_set(type, date):
temporary_folder, folder = helper.create_working_folder()
photo_name = 'photo.{}'.format(type)
photo_file = helper.get_file(photo_name)
origin = '{}/{}'.format(folder, photo_name)
if not photo_file:
photo_file = helper.download_file(photo_name, folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('{} file not downlaoded'.format(type))
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert(date), '{} date {}'.format(type, metadata['date_taken'])
assert helper.isclose(metadata['latitude'], 11.1111111111), '{} lat {}'.format(type, metadata['latitude'])
assert helper.isclose(metadata['longitude'], 99.9999999999), '{} lon {}'.format(type, metadata['latitude'])
示例5: test_set_metadata_on_rw2
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_metadata_on_rw2():
raise SkipTest('gh-94 Writing to RW2 images is not supported')
temporary_folder, folder = helper.create_working_folder()
photo_file = helper.get_file('photo.rw2')
origin = '%s/photo.rw2' % folder
if not photo_file:
photo_file = helper.download_file('photo.rw2', folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('rw2 file not downlaoded')
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert((2014, 11, 19, 23, 7, 44, 2, 323, 0)), metadata['date_taken']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
示例6: test_set_location
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_location():
raise SkipTest('gh-31, precision is lost in conversion from decimal to dms')
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
# Verify that original photo has no location information
assert origin_metadata['latitude'] is None, origin_metadata['latitude']
assert origin_metadata['longitude'] is None, origin_metadata['longitude']
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
# @TODO: understand why the decimal to degree conversion loses accuracy
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
示例7: test_set_metadata_on_arw
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_metadata_on_arw():
temporary_folder, folder = helper.create_working_folder()
photo_file = helper.get_file('photo.arw')
origin = '%s/photo.arw' % folder
if not photo_file:
photo_file = helper.download_file('photo.arw', folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('arw file not downlaoded')
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_location(11.1111111111, 99.9999999999)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert((2007, 4, 8, 17, 41, 18, 6, 98, 0)), metadata['date_taken']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
示例8: _test_photo_type_get
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def _test_photo_type_get(type, date):
temporary_folder, folder = helper.create_working_folder()
photo_name = 'photo.{}'.format(type)
photo_file = helper.get_file(photo_name)
origin = '{}/{}'.format(folder, photo_name)
if not photo_file:
photo_file = helper.download_file(photo_name, folder)
if not photo_file or not os.path.isfile(photo_file):
raise SkipTest('{} file not downlaoded'.format(type))
# downloading for each test is costly so we save it in the working directory
file_path_save_as = helper.get_file_path(photo_name)
if os.path.isfile(photo_file):
shutil.copyfile(photo_file, file_path_save_as)
shutil.copyfile(photo_file, origin)
photo = Photo(origin)
metadata = photo.get_metadata()
shutil.rmtree(folder)
assert metadata['date_taken'] == helper.time_convert(date), '{} date {}'.format(type, metadata['date_taken'])
示例9: test_set_metadata
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_metadata():
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
metadata = photo.get_metadata()
assert metadata['title'] == None, metadata['title']
new_title = 'Some Title'
photo.set_metadata(title = new_title)
new_metadata = photo.get_metadata()
assert new_metadata['title'] == new_title, new_metadata['title']
示例10: test_set_metadata_basename
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_metadata_basename():
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
metadata = photo.get_metadata()
assert metadata['base_name'] == 'photo', metadata['base_name']
new_basename = 'Some Base Name'
photo.set_metadata_basename(new_basename)
new_metadata = photo.get_metadata()
assert new_metadata['base_name'] == new_basename, new_metadata['base_name']
示例11: test_set_title
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_title():
temporary_folder, folder = helper.create_working_folder()
origin = "%s/photo.jpg" % folder
shutil.copyfile(helper.get_file("plain.jpg"), origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_title("my photo title")
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata["title"] == "my photo title", metadata["title"]
示例12: test_set_title_non_ascii
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_title_non_ascii():
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
unicode_title = u'形声字 / 形聲字'
status = photo.set_title(unicode_title)
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata['title'] == unicode_title, metadata['title']
示例13: test_set_title_non_ascii
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_title_non_ascii():
raise SkipTest("gh-27, non-ascii characters")
temporary_folder, folder = helper.create_working_folder()
origin = "%s/photo.jpg" % folder
shutil.copyfile(helper.get_file("plain.jpg"), origin)
photo = Photo(origin)
origin_metadata = photo.get_metadata()
status = photo.set_title("形声字 / 形聲字")
assert status == True, status
photo_new = Photo(origin)
metadata = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata["title"] == "形声字 / 形聲字", metadata["title"]
示例14: test_set_album
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_set_album():
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)
photo = Photo(origin)
metadata = photo.get_metadata()
assert metadata['album'] is None, metadata['album']
status = photo.set_album('Test Album')
assert status == True, status
photo_new = Photo(origin)
metadata_new = photo_new.get_metadata()
shutil.rmtree(folder)
assert metadata_new['album'] == 'Test Album', metadata_new['album']
示例15: test_update_location_on_photo
# 需要导入模块: from elodie.media.photo import Photo [as 别名]
# 或者: from elodie.media.photo.Photo import get_metadata [as 别名]
def test_update_location_on_photo():
temporary_folder, folder = helper.create_working_folder()
temporary_folder_destination, folder_destination = helper.create_working_folder()
origin = "%s/plain.jpg" % folder
shutil.copyfile(helper.get_file("plain.jpg"), origin)
photo = Photo(origin)
metadata = photo.get_metadata()
reset_hash_db()
status = elodie.update_location(photo, origin, "Sunnyvale, CA")
restore_hash_db()
photo_processed = Photo(origin)
metadata_processed = photo_processed.get_metadata()
shutil.rmtree(folder)
shutil.rmtree(folder_destination)
assert status == True, status
assert metadata["latitude"] != metadata_processed["latitude"]
assert helper.isclose(metadata_processed["latitude"], 37.36883), metadata_processed["latitude"]
assert helper.isclose(metadata_processed["longitude"], -122.03635), metadata_processed["longitude"]