def test_get_exif_tags(): test_image = '11.jpg' src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir1', 'test1', test_image) data = get_exif_data(src_file) simple = get_exif_tags(data) assert simple['fstop'] == 3.9 assert simple['focal'] == 12.0 assert simple['iso'] == 50 assert simple['Make'] == 'NIKON' assert simple['datetime'] == 'Sunday, 22. January 2006' if PIL.PILLOW_VERSION == '3.0.0': assert simple['exposure'] == 0.00100603 else: assert simple['exposure'] == '100603/100000000' data = {'FNumber': [1, 0], 'FocalLength': [1, 0], 'ExposureTime': 10} simple = get_exif_tags(data) assert 'fstop' not in simple assert 'focal' not in simple assert simple['exposure'] == '10' data = {'ExposureTime': '--', 'DateTimeOriginal': '---', 'GPSInfo': {'GPSLatitude': ((34, 0), (1, 0), (4500, 100)), 'GPSLatitudeRef': 'N', 'GPSLongitude': ((116, 0), (8, 0), (3900, 100)), 'GPSLongitudeRef': 'W'}} simple = get_exif_tags(data) assert 'exposure' not in simple assert 'datetime' not in simple assert 'gps' not in simple
def test_exif_copy(tmpdir): "Test if EXIF data can transfered copied to the resized image." test_image = "11.jpg" src_file = os.path.join(CURRENT_DIR, "sample", "pictures", "dir1", "test1", test_image) dst_file = str(tmpdir.join(test_image)) settings = create_settings(img_size=(300, 400), copy_exif_data=True) generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert simple["iso"] == 50 settings["copy_exif_data"] = False generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert not simple
def test_exif_copy(tmpdir): "Test if EXIF data can transfered copied to the resized image." test_image = '11.jpg' src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir1', 'test1', test_image) dst_file = str(tmpdir.join(test_image)) settings = create_settings(img_size=(300, 400), copy_exif_data=True) generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert simple['iso'] == 50 settings['copy_exif_data'] = False generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert not simple
def test_exif_copy(tmpdir): "Test if EXIF data can transferred copied to the resized image." test_image = '11.jpg' src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir1', 'test1', test_image) dst_file = str(tmpdir.join(test_image)) settings = create_settings(img_size=(300, 400), copy_exif_data=True) generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert simple['iso'] == 50 settings['copy_exif_data'] = False generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert not simple
def test_exif_gps(tmpdir): """Test reading out correct geo tags""" test_image = "flickr_jerquiaga_2394751088_cc-by-nc.jpg" src_file = os.path.join(CURRENT_DIR, "sample", "pictures", "dir1", "test1", test_image) dst_file = str(tmpdir.join(test_image)) settings = create_settings(img_size=(400, 300), copy_exif_data=True) generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert "gps" in simple lat = 34.029167 lon = -116.144167 assert abs(simple["gps"]["lat"] - lat) < 0.0001 assert abs(simple["gps"]["lon"] - lon) < 0.0001
def test_exif_gps(tmpdir): """Test reading out correct geo tags""" test_image = 'flickr_jerquiaga_2394751088_cc-by-nc.jpg' src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir1', 'test1', test_image) dst_file = str(tmpdir.join(test_image)) settings = create_settings(img_size=(400, 300), copy_exif_data=True) generate_image(src_file, dst_file, settings) simple = get_exif_tags(get_exif_data(dst_file)) assert 'gps' in simple lat = 34.029167 lon = -116.144167 assert abs(simple['gps']['lat'] - lat) < 0.0001 assert abs(simple['gps']['lon'] - lon) < 0.0001
def test_get_exif_tags(): test_image = '11.jpg' src_file = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir1', 'test1', test_image) data = get_exif_data(src_file) simple = get_exif_tags(data, datetime_format='%d/%m/%Y') assert simple['fstop'] == 3.9 assert simple['focal'] == 12.0 assert simple['iso'] == 50 assert simple['Make'] == 'NIKON' assert simple['datetime'] == '22/01/2006' try: # Pillow 7.2+ assert simple['exposure'] == '0.00100603' except Exception: assert simple['exposure'] == '100603/100000000' data = {'FNumber': [1, 0], 'FocalLength': [1, 0], 'ExposureTime': 10} simple = get_exif_tags(data) assert 'fstop' not in simple assert 'focal' not in simple assert simple['exposure'] == '10' data = { 'ExposureTime': '--', 'DateTimeOriginal': '---', 'GPSInfo': { 'GPSLatitude': ((34, 0), (1, 0), (4500, 100)), 'GPSLatitudeRef': 'N', 'GPSLongitude': ((116, 0), (8, 0), (3900, 100)), 'GPSLongitudeRef': 'W', }, } simple = get_exif_tags(data) assert 'exposure' not in simple assert 'datetime' not in simple assert 'gps' not in simple