[Python-modules-commits] [sorl-thumbnail] 03/17: Split orientation test into pixel and EXIF comparison.

Wolfgang Borgert debacle at moszumanska.debian.org
Wed Jan 6 21:05:25 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 084d80afd7d3efd3be6dc2e91b81734525e35b8f
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 | 37 +++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/tests/thumbnail_tests/test_templatetags.py b/tests/thumbnail_tests/test_templatetags.py
index c774dea..9281bb3 100644
--- a/tests/thumbnail_tests/test_templatetags.py
+++ b/tests/thumbnail_tests/test_templatetags.py
@@ -76,8 +76,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 = pjoin(settings.MEDIA_ROOT, 'data_pixels')
+        shutil.copytree(settings.DATA_ROOT, data_dir)
+        ref = Image.open(pjoin(data_dir, '1_topleft.jpg'))
         top = ref.getpixel((14, 7))
         left = ref.getpixel((7, 14))
         engine = PILEngine()
@@ -101,16 +103,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 = pjoin(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