当前位置: 首页>>代码示例>>Python>>正文


Python photo.Photo类代码示例

本文整理汇总了Python中elodie.media.photo.Photo的典型用法代码示例。如果您正苦于以下问题:Python Photo类的具体用法?Python Photo怎么用?Python Photo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Photo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_utime_without_exif_date

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
开发者ID:jmathai,项目名称:elodie,代码行数:28,代码来源:filesystem_test.py

示例2: test_set_location

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']
开发者ID:scudderfish,项目名称:elodie,代码行数:26,代码来源:photo_test.py

示例3: _test_photo_type_set

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'])
开发者ID:jmathai,项目名称:elodie,代码行数:29,代码来源:photo_test.py

示例4: test_update_time_on_photo

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"
    ]
开发者ID:jmathai,项目名称:elodie,代码行数:25,代码来源:elodie_test.py

示例5: _test_photo_type_get

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'])
开发者ID:jmathai,项目名称:elodie,代码行数:25,代码来源:photo_test.py

示例6: test_set_location

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']
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:25,代码来源:photo_test.py

示例7: test_set_metadata_on_rw2

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']
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:29,代码来源:photo_test.py

示例8: test_get_coordinates_without_exif

def test_get_coordinates_without_exif():
    photo = Photo(helper.get_file('no-exif.jpg'))
    latitude = photo.get_coordinate('latitude')
    longitude = photo.get_coordinate('longitude')

    assert latitude is None, latitude
    assert longitude is None, longitude
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:7,代码来源:photo_test.py

示例9: test_set_metadata_on_arw

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']
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:28,代码来源:photo_test.py

示例10: test_get_date_taken_without_exif

def test_get_date_taken_without_exif():
    source = helper.get_file('no-exif.jpg')
    photo = Photo(source)
    date_taken = photo.get_date_taken()

    date_taken_from_file = time.gmtime(min(os.path.getmtime(source), os.path.getctime(source)))

    assert date_taken == date_taken_from_file, date_taken
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:8,代码来源:photo_test.py

示例11: test_set_metadata_basename

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']
开发者ID:jmathai,项目名称:elodie,代码行数:18,代码来源:base_test.py

示例12: test_set_metadata

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']
开发者ID:jmathai,项目名称:elodie,代码行数:18,代码来源:base_test.py

示例13: test_set_title

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']
开发者ID:GonzaloAlvarez,项目名称:elodie,代码行数:19,代码来源:photo_test.py

示例14: test_set_date_taken

def test_set_date_taken():
    temporary_folder, folder = helper.create_working_folder()

    origin = "%s/photo.jpg" % folder
    shutil.copyfile(helper.get_file("plain.jpg"), origin)

    photo = Photo(origin)
    status = photo.set_date_taken(datetime.datetime(2013, 9, 30, 7, 6, 5))

    assert status == True, status

    photo_new = Photo(origin)
    metadata = photo_new.get_metadata()

    date_taken = metadata["date_taken"]

    shutil.rmtree(folder)

    assert date_taken == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata["date_taken"]
开发者ID:wallrat,项目名称:elodie,代码行数:19,代码来源:photo_test.py

示例15: test_set_title_non_ascii

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']
开发者ID:jmathai,项目名称:elodie,代码行数:20,代码来源:photo_test.py


注:本文中的elodie.media.photo.Photo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。