Filippo Giunchedi has submitted this change and it was merged.

Change subject: Upgrade to 0.1.26
......................................................................


Upgrade to 0.1.26

Change-Id: Ieb06f8ba206c67b25019389ede86d9814a1b919c
---
M debian/changelog
M setup.py
M tests/integration/__init__.py
A tests/integration/originals/Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
M tests/integration/test_https_loader.py
M tests/integration/test_proxy_loader.py
M tests/integration/test_types.py
A 
tests/integration/thumbnails/300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
A wikimedia_thumbor/engine/gif/__init__.py
A wikimedia_thumbor/engine/gif/gif.py
M wikimedia_thumbor/engine/imagemagick/imagemagick.py
11 files changed, 94 insertions(+), 13 deletions(-)

Approvals:
  Filippo Giunchedi: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/debian/changelog b/debian/changelog
index 0d8f61d..cbf894e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,20 +1,26 @@
+python-thumbor-wikimedia (0.1.26-1) jessie-wikimedia; urgency=low
+
+  * New upstream release
+
+ -- Gilles Dubuc <gil...@wikimedia.org>  Wed, 12 Oct 2016 15:40:00 +0000
+
 python-thumbor-wikimedia (0.1.25-1) jessie-wikimedia; urgency=low
 
   * New upstream release
 
- -- Gilles Dubuc <gil...@wikimedia.org>  Mon, 10 OCt 2016 15:39:00 +0000
+ -- Gilles Dubuc <gil...@wikimedia.org>  Mon, 10 Oct 2016 15:39:00 +0000
 
 python-thumbor-wikimedia (0.1.24-1) jessie-wikimedia; urgency=low
 
   * New upstream release
 
- -- Gilles Dubuc <gil...@wikimedia.org>  Fri, 7 OCt 2016 17:27:00 +0000
+ -- Gilles Dubuc <gil...@wikimedia.org>  Fri, 7 Oct 2016 17:27:00 +0000
 
 python-thumbor-wikimedia (0.1.23-1) jessie-wikimedia; urgency=low
 
   * New upstream release
 
- -- Gilles Dubuc <gil...@wikimedia.org>  Fri, 7 OCt 2016 14:19:00 +0000
+ -- Gilles Dubuc <gil...@wikimedia.org>  Fri, 7 Oct 2016 14:19:00 +0000
 
 python-thumbor-wikimedia (0.1.22-1) jessie-wikimedia; urgency=low
 
@@ -23,7 +29,7 @@
    - add python-urllib3 as build dependency
    - add python-manhole as dependency
 
- -- Gilles Dubuc <gil...@wikimedia.org>  Mon, 3 OCt 2016 11:04:00 +0000
+ -- Gilles Dubuc <gil...@wikimedia.org>  Mon, 3 Oct 2016 11:04:00 +0000
 
 python-thumbor-wikimedia (0.1.21-1) jessie-wikimedia; urgency=low
 
diff --git a/setup.py b/setup.py
index 5ad4104..7256c2f 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@
 
 setup(
     name='wikimedia_thumbor',
-    version='0.1.25',
+    version='0.1.26',
     url='https://phabricator.wikimedia.org/diffusion/THMBREXT/',
     license='MIT',
     author='Gilles Dubuc, Wikimedia Foundation',
diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py
index 648028a..dbddd27 100644
--- a/tests/integration/__init__.py
+++ b/tests/integration/__init__.py
@@ -35,7 +35,6 @@
             'originals'
         )
         cfg.ENGINE = 'wikimedia_thumbor.engine.proxy'
-        cfg.USE_GIFSICLE_ENGINE = True
         cfg.RESPECT_ORIENTATION = True
 
         cfg.FFMPEG_PATH = which('ffmpeg')
@@ -80,6 +79,7 @@
             ('wikimedia_thumbor.engine.vips', ['tiff', 'png']),
             ('wikimedia_thumbor.engine.tiff', ['tiff']),
             ('wikimedia_thumbor.engine.ghostscript', ['pdf']),
+            ('wikimedia_thumbor.engine.gif', ['gif']),
             ('wikimedia_thumbor.engine.imagemagick', ['jpg', 'png']),
         ]
 
diff --git 
a/tests/integration/originals/Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
 
b/tests/integration/originals/Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
new file mode 100644
index 0000000..97f0464
--- /dev/null
+++ 
b/tests/integration/originals/Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
Binary files differ
diff --git a/tests/integration/test_https_loader.py 
b/tests/integration/test_https_loader.py
index ebe0626..fb97863 100644
--- a/tests/integration/test_https_loader.py
+++ b/tests/integration/test_https_loader.py
@@ -105,3 +105,13 @@
             0.92,
             1.01
         )
+
+    def test_gif(self):
+        self.run_and_check_ssim_and_size(
+            'unsafe/300x/https://upload.wikimedia.org/'
+            + 'wikipedia/commons/f/fb/Pacific-Electric-Red-Cars-Awaiting-'
+            + 'Destruction.gif',
+            '300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif',
+            0.98,
+            1.1
+        )
diff --git a/tests/integration/test_proxy_loader.py 
b/tests/integration/test_proxy_loader.py
index 0892318..b1b1f93 100644
--- a/tests/integration/test_proxy_loader.py
+++ b/tests/integration/test_proxy_loader.py
@@ -36,3 +36,12 @@
             0.96,
             1.1
         )
+
+    def test_proxied_gif(self):
+        self.run_and_check_ssim_and_size(
+            'unsafe/300x/https://upload.wikimedia.org/wikipedia/commons/f/fb/'
+            + 'Pacific-Electric-Red-Cars-Awaiting-Destruction.gif',
+            '300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif',
+            0.98,
+            1.1
+        )
diff --git a/tests/integration/test_types.py b/tests/integration/test_types.py
index aa070e0..c5a6354 100644
--- a/tests/integration/test_types.py
+++ b/tests/integration/test_types.py
@@ -188,3 +188,11 @@
             0.99,
             1.1
         )
+
+    def test_gif(self):
+        self.run_and_check_ssim_and_size(
+            'unsafe/300x/Pacific-Electric-Red-Cars-Awaiting-Destruction.gif',
+            '300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif',
+            0.98,
+            1.1
+        )
diff --git 
a/tests/integration/thumbnails/300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
 
b/tests/integration/thumbnails/300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
new file mode 100644
index 0000000..887fc4d
--- /dev/null
+++ 
b/tests/integration/thumbnails/300px-Pacific-Electric-Red-Cars-Awaiting-Destruction.gif
Binary files differ
diff --git a/wikimedia_thumbor/engine/gif/__init__.py 
b/wikimedia_thumbor/engine/gif/__init__.py
new file mode 100644
index 0000000..140730b
--- /dev/null
+++ b/wikimedia_thumbor/engine/gif/__init__.py
@@ -0,0 +1,3 @@
+from .gif import Engine
+
+__all__ = ['Engine']
diff --git a/wikimedia_thumbor/engine/gif/gif.py 
b/wikimedia_thumbor/engine/gif/gif.py
new file mode 100644
index 0000000..0c6543d
--- /dev/null
+++ b/wikimedia_thumbor/engine/gif/gif.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# thumbor imaging service
+# https://github.com/thumbor/thumbor/wiki
+
+# Licensed under the MIT license:
+# http://www.opensource.org/licenses/mit-license
+# Copyright (c) 2011 globo.com timeh...@corp.globo.com
+# Copyright (c) 2015 Wikimedia Foundation
+
+# GIF engine
+# This makes GIF handling compatible with the wikimedia https loader
+# Actual processing is handled by the Thumbor built-in gifsicle-based engine
+
+from thumbor.engines.gif import Engine as BaseEngine
+from wikimedia_thumbor.engine import BaseWikimediaEngine
+from wikimedia_thumbor.shell_runner import ShellRunner
+
+BaseWikimediaEngine.add_format(
+    'image/gif',
+    '.gif',
+    lambda buffer: Engine.is_gif(buffer)
+)
+
+
+class Engine(BaseEngine):
+    @classmethod
+    def is_gif(cls, buffer):
+        return buffer.startswith('GIF8')
+
+    def load(self, buffer, extension):
+        if hasattr(self.context, 'wikimedia_original_file'):
+            fname = self.context.wikimedia_original_file.name
+            with open(fname, 'r') as content_file:
+                buffer = content_file.read()
+            ShellRunner.rm_f(fname)
+
+        return super(Engine, self).load(buffer, extension)
diff --git a/wikimedia_thumbor/engine/imagemagick/imagemagick.py 
b/wikimedia_thumbor/engine/imagemagick/imagemagick.py
index 60ad698..d9d82be 100644
--- a/wikimedia_thumbor/engine/imagemagick/imagemagick.py
+++ b/wikimedia_thumbor/engine/imagemagick/imagemagick.py
@@ -192,23 +192,28 @@
             '-m',
         ]
 
-        stdout = Engine.exiftool.command(
+        self.icc_profile_saved = Engine.exiftool.command(
             pre=command,
             context=self.context,
             buffer=buffer
         )
 
-        profile_file = NamedTemporaryFile(delete=False)
-        profile_file.write(stdout)
-        profile_file.close()
-
-        self.icc_profile_path = profile_file.name
-
     def process_exif(self, buffer):
+        logger.debug('[IM] Processing EXIF')
+
         command = [
             '-m',
             '-all=',  # Strip all existing metadata
         ]
+
+        # Create the temp file when we need it
+        if hasattr(self, 'icc_profile_saved'):
+            logger.debug('[IM] Putting saved ICC profile into temp file')
+            profile_file = NamedTemporaryFile(delete=False)
+            profile_file.write(self.icc_profile_saved)
+            profile_file.close()
+            self.icc_profile_path = profile_file.name
+            del self.icc_profile_saved
 
         # Copy the ICC profile
         if hasattr(self, 'icc_profile_path'):
@@ -237,6 +242,7 @@
         if (hasattr(self, 'icc_profile_path')
                 and self.icc_profile_path != tinyrgb_path):
             ShellRunner.rm_f(self.icc_profile_path)
+            del self.icc_profile_path
 
         return stdout
 

-- 
To view, visit https://gerrit.wikimedia.org/r/315507
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb06f8ba206c67b25019389ede86d9814a1b919c
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/python-thumbor-wikimedia
Gerrit-Branch: master
Gerrit-Owner: Gilles <gdu...@wikimedia.org>
Gerrit-Reviewer: Filippo Giunchedi <fgiunch...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to