[Python-modules-commits] [sorl-thumbnail] 02/15: Split orientation test into pixel and EXIF comparison.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 5 01:39:42 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository sorl-thumbnail.
commit 59611f8187b383c8692cf3ffb94be9b2ec505534
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Thu Oct 8 13:53:15 2015 -0700
Split orientation test into pixel and EXIF comparison.
Skip these tests if graphicsmagick or pgmagick is used as the engine. Both
don't synchronize the EXIF orientation with the actual orientation of the
image.
Last-Update: 2015-01-27
Forwarded: no
Patch-Name: orientation.patch
---
tests/thumbnail_tests/test_templatetags.py | 39 +++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/tests/thumbnail_tests/test_templatetags.py b/tests/thumbnail_tests/test_templatetags.py
index c774dea..d545519 100644
--- a/tests/thumbnail_tests/test_templatetags.py
+++ b/tests/thumbnail_tests/test_templatetags.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import os
import re
+import shutil
+import unittest
from subprocess import Popen, PIPE
from PIL import Image
@@ -76,8 +78,10 @@ class TemplateTestCaseA(BaseTestCase):
m = re.search('Interlace: None', str(p.stdout.read()))
self.assertEqual(bool(m), True)
- def test_orientation(self):
- ref = Image.open(os.path.join(DATA_DIR, '1_topleft.jpg'))
+ def test_orientation_pixels(self):
+ data_dir = os.path.join(settings.MEDIA_ROOT, 'data_pixels')
+ shutil.copytree(settings.DATA_ROOT, data_dir)
+ ref = Image.open(os.path.join(data_dir, '1_topleft.jpg'))
top = ref.getpixel((14, 7))
left = ref.getpixel((7, 14))
engine = PILEngine()
@@ -101,16 +105,45 @@ class TemplateTestCaseA(BaseTestCase):
)
for name in data_images:
- th = self.BACKEND.get_thumbnail('data/%s' % name, '30x30')
+ th = self.BACKEND.get_thumbnail('data_pixels/%s' % name, '30x30')
im = engine.get_image(th)
self.assertLess(epsilon(top, im.getpixel((14, 7))), 10)
self.assertLess(epsilon(left, im.getpixel((7, 14))), 10)
+
+ shutil.rmtree(data_dir)
+
+ @unittest.skipIf(settings.THUMBNAIL_ENGINE in (
+ "sorl.thumbnail.engines.pgmagick_engine.Engine",
+ "sorl.thumbnail.engines.convert_engine.Engine",
+ ),
+ "graphicsmagick and pgmagick do not correct the orientation in the EXIF tag")
+ def test_orientation_exif(self):
+ data_dir = os.path.join(settings.MEDIA_ROOT, 'data_exif')
+ shutil.copytree(settings.DATA_ROOT, data_dir)
+ engine = PILEngine()
+
+ data_images = (
+ '1_topleft.jpg',
+ '2_topright.jpg',
+ '3_bottomright.jpg',
+ '4_bottomleft.jpg',
+ '5_lefttop.jpg',
+ '6_righttop.jpg',
+ '7_rightbottom.jpg',
+ '8_leftbottom.jpg'
+ )
+
+ for name in sorted(os.listdir(data_dir)):
+ th = self.BACKEND.get_thumbnail('data_exif/%s' % name, '30x30')
+ im = engine.get_image(th)
exif = im._getexif()
if exif:
self.assertEqual(exif.get(0x0112), 1)
+ shutil.rmtree(data_dir)
+
class TemplateTestCaseB(BaseTestCase):
def test_url(self):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sorl-thumbnail.git
More information about the Python-modules-commits
mailing list