From 485b258692fc70c62e7a7d61507541560b240c7d Mon Sep 17 00:00:00 2001 From: David Siroky Date: Thu, 17 Dec 2015 09:37:25 +0100 Subject: [PATCH 1/5] better exposure time fraction --- sigal/image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sigal/image.py b/sigal/image.py index bcf4bf2..777e271 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -36,6 +36,7 @@ import PIL import pilkit.processors import sys import warnings +import fractions from copy import deepcopy from datetime import datetime @@ -254,7 +255,7 @@ def get_exif_tags(data): exptime = data['ExposureTime'] if isinstance(exptime, tuple): try: - simple['exposure'] = exptime[0] / float(exptime[1]) + simple['exposure'] = str(fractions.Fraction(exptime[0], exptime[1])) except IndexError: # Pillow == 3.0 simple['exposure'] = exptime[0] From c044d276b38e565a96d7b3d035046ad3ab4f4bfe Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Fri, 8 Jan 2016 00:11:17 +0100 Subject: [PATCH 2/5] Show Pillow version in the tests header --- tests/conftest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 85c7b32..052eb6d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import PIL import pytest from sigal.settings import read_settings @@ -12,3 +13,7 @@ CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) def settings(): """Read the sample config file.""" return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py')) + + +def pytest_report_header(config): + return "project deps: Pillow-{}".format(PIL.PILLOW_VERSION) From eaddfe587e43153787f1f40aa750deb64c44d83e Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Fri, 8 Jan 2016 00:11:40 +0100 Subject: [PATCH 3/5] Test Pillow versions with tox --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 946bfe4..bfe256a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,11 @@ [tox] -envlist = py27,py33,py34,py35,report,check +envlist = py{27,33,34,35}-pillow{30,31},report,check [testenv] commands = py.test --cov sigal --cov-report term-missing deps = + pillow30: Pillow==3.0.0 + pillow31: Pillow>3.0.0 pytest pytest-capturelog pytest-cov From 0622f2666c8aa3b69cc07ad517a9ef22b92686f0 Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Fri, 8 Jan 2016 00:12:33 +0100 Subject: [PATCH 4/5] xfail GPS test only for Pillow 3.0.0 --- tests/test_image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_image.py b/tests/test_image.py index 224cb4f..0faa62b 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -1,6 +1,7 @@ # -*- coding:utf-8 -*- import os +import PIL import pytest from PIL import Image @@ -142,7 +143,8 @@ def test_exif_copy(tmpdir): assert not simple -@pytest.mark.xfail +@pytest.mark.xfail(PIL.PILLOW_VERSION == '3.0.0', + reason="Pillow 3.0.0 was broken") def test_exif_gps(tmpdir): """Test reading out correct geo tags""" From f819f883d461a7022b7df0c57cc17ec238a5ed85 Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Fri, 8 Jan 2016 00:13:07 +0100 Subject: [PATCH 5/5] Fix test with fraction exposure --- sigal/image.py | 3 ++- tests/test_image.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sigal/image.py b/sigal/image.py index 777e271..d46ca71 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -255,7 +255,8 @@ def get_exif_tags(data): exptime = data['ExposureTime'] if isinstance(exptime, tuple): try: - simple['exposure'] = str(fractions.Fraction(exptime[0], exptime[1])) + simple['exposure'] = str(fractions.Fraction(exptime[0], + exptime[1])) except IndexError: # Pillow == 3.0 simple['exposure'] = exptime[0] diff --git a/tests/test_image.py b/tests/test_image.py index 0faa62b..df0cedc 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -105,7 +105,10 @@ def test_get_exif_tags(): assert simple['iso'] == 50 assert simple['Make'] == 'NIKON' assert simple['datetime'] == 'Sunday, 22. January 2006' - assert simple['exposure'] == 0.00100603 + 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)