Gilles has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357978 )

Change subject: Upgrade to 0.1.40
......................................................................

Upgrade to 0.1.40

Bug: T166938
Bug: T167462
Change-Id: I5bcc3688b2caecc67030b775561e27bf1208342b
---
M debian/changelog
M debian/control
M setup.py
M tests/integration/__init__.py
A tests/integration/originals/Album_en_blanco_y_negro.webp
M tests/integration/test_types.py
A tests/integration/thumbnails/300px-Album_en_blanco_y_negro.webp.png
M wikimedia_thumbor/engine/__init__.py
M wikimedia_thumbor/engine/imagemagick/imagemagick.py
M wikimedia_thumbor/handler/images/images.py
10 files changed, 55 insertions(+), 26 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/operations/debs/python-thumbor-wikimedia 
refs/changes/78/357978/1

diff --git a/debian/changelog b/debian/changelog
index 55783f4..f9b8395 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+python-thumbor-wikimedia (0.1.40-1) jessie-wikimedia; urgency=low
+
+  * New upstream release
+  * debian/control
+    - add dependency on webp
+    - bump thumbor minimum version to 6.3.2
+
+ -- Gilles Dubuc <gil...@wikimedia.org>  Fri, 9 Jun 2017 09:10:00 +0000
+
 python-thumbor-wikimedia (0.1.39-1) jessie-wikimedia; urgency=low
 
   * New upstream release
diff --git a/debian/control b/debian/control
index 16ecac3..4f66e7d 100644
--- a/debian/control
+++ b/debian/control
@@ -23,14 +23,15 @@
                python-swiftclient (>= 2.5.0),
                python-thumbor-community-core,
                python-urllib3,
-               thumbor (>= 6.0.1),
+               thumbor (>= 6.3.2),
+               webp,
                xcftools
 X-Python-Version: >= 2.6
 Homepage: https://phabricator.wikimedia.org/diffusion/THMBREXT/
 
 Package: python-thumbor-wikimedia
 Architecture: all
-Depends: ${misc:Depends}, ${python:Depends}, djvulibre-bin, ffmpeg, 
ghostscript, gifsicle (>= 1.88), imagemagick, libimage-exiftool-perl, 
librsvg2-bin, libvips-tools, python-libthumbor (>= 1.3.2), python-manhole, 
python-memcache, python-swiftclient (>= 2.5.0), python-thumbor-community-core, 
thumbor (>= 6.0.1), xcftools
+Depends: ${misc:Depends}, ${python:Depends}, djvulibre-bin, ffmpeg, 
ghostscript, gifsicle (>= 1.88), imagemagick, libimage-exiftool-perl, 
librsvg2-bin, libvips-tools, python-libthumbor (>= 1.3.2), python-manhole, 
python-memcache, python-swiftclient (>= 2.5.0), python-thumbor-community-core, 
thumbor (>= 6.3.2), webp, xcftools
 Suggests: cgroup-tools
 Provides: ${python:Provides}
 Description: Thumbor wikimedia extensions
diff --git a/setup.py b/setup.py
index dd695e8..6f6c5c2 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@
 
 setup(
     name='wikimedia_thumbor',
-    version='0.1.39',
+    version='0.1.40',
     url='https://phabricator.wikimedia.org/diffusion/THMBREXT/',
     license='MIT',
     author='Gilles Dubuc, Wikimedia Foundation',
@@ -26,7 +26,7 @@
         'manhole',
         'python-memcached',
         'python-swiftclient',
-        'thumbor==6.0.1'
+        'thumbor>=6.3.2'
     ],
     extras_require={
         'tests': tests_require,
diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py
index c2b9a96..ea65528 100644
--- a/tests/integration/__init__.py
+++ b/tests/integration/__init__.py
@@ -84,7 +84,7 @@
             ('wikimedia_thumbor.engine.tiff', ['tiff']),
             ('wikimedia_thumbor.engine.ghostscript', ['pdf']),
             ('wikimedia_thumbor.engine.gif', ['gif']),
-            ('wikimedia_thumbor.engine.imagemagick', ['jpg', 'png']),
+            ('wikimedia_thumbor.engine.imagemagick', ['jpg', 'png', 'webp']),
         ]
 
         cfg.FILTERS = [
diff --git a/tests/integration/originals/Album_en_blanco_y_negro.webp 
b/tests/integration/originals/Album_en_blanco_y_negro.webp
new file mode 100644
index 0000000..a0680d3
--- /dev/null
+++ b/tests/integration/originals/Album_en_blanco_y_negro.webp
Binary files differ
diff --git a/tests/integration/test_types.py b/tests/integration/test_types.py
index 13bad6c..cb76bbb 100644
--- a/tests/integration/test_types.py
+++ b/tests/integration/test_types.py
@@ -20,7 +20,7 @@
             # Mediawiki generates incorrect dimensions in this test case
             # resulting in soft djvu thumbs
             0.88,
-            1.0
+            1.1
         )
 
     def test_djvu_without_page_filter(self):
@@ -30,7 +30,7 @@
             # Mediawiki generates incorrect dimensions in this test case
             # resulting in soft djvu thumbs
             0.87,
-            1.1
+            1.2
         )
 
     def test_djvu_with_out_of_bounds_page(self):
@@ -209,7 +209,7 @@
             
'thumbor/unsafe/400x/filters:conditional_sharpen(0.0,0.0,0.0,0.0,0.0)/' +
             'PNG_transparency_demonstration_1.png',
             '400px-PNG_transparency_demonstration_1.png',
-            0.99,
+            0.97,
             1.1
         )
 
@@ -226,3 +226,11 @@
             1.0,
             1.1
         )
+
+    def test_webp(self):
+        self.run_and_check_ssim_and_size(
+            
'thumbor/unsafe/300x/filters:format(png)/Album_en_blanco_y_negro.webp',
+            '300px-Album_en_blanco_y_negro.webp.png',
+            0.99,
+            1.1
+        )
diff --git 
a/tests/integration/thumbnails/300px-Album_en_blanco_y_negro.webp.png 
b/tests/integration/thumbnails/300px-Album_en_blanco_y_negro.webp.png
new file mode 100644
index 0000000..2e409bd
--- /dev/null
+++ b/tests/integration/thumbnails/300px-Album_en_blanco_y_negro.webp.png
Binary files differ
diff --git a/wikimedia_thumbor/engine/__init__.py 
b/wikimedia_thumbor/engine/__init__.py
index e419d0d..7622b9b 100644
--- a/wikimedia_thumbor/engine/__init__.py
+++ b/wikimedia_thumbor/engine/__init__.py
@@ -26,24 +26,6 @@
 
 
 class BaseWikimediaEngine(IMEngine):
-    @classmethod
-    def add_format(cls, mime, ext, fn):
-        # Unfortunately there is no elegant way to extend Thumbor to support
-        # a new MIME type, which is why this monkey-patching is done here
-        from thumbor.utils import EXTENSION
-        EXTENSION[mime] = ext
-        from thumbor.engines import BaseEngine
-        old_get_mimetype = BaseEngine.get_mimetype
-
-        @classmethod
-        def new_get_mimetype(cls, buffer):
-            if fn(buffer):
-                return mime
-
-            return old_get_mimetype(buffer)
-
-        BaseEngine.get_mimetype = new_get_mimetype
-
     def read(self, extension=None, quality=None):
         # When requests don't come through the wikimedia url handler
         # and the format isn't specified, we default to JPG output
diff --git a/wikimedia_thumbor/engine/imagemagick/imagemagick.py 
b/wikimedia_thumbor/engine/imagemagick/imagemagick.py
index bd1bf6a..52585ed 100644
--- a/wikimedia_thumbor/engine/imagemagick/imagemagick.py
+++ b/wikimedia_thumbor/engine/imagemagick/imagemagick.py
@@ -27,6 +27,24 @@
 class Engine(BaseEngine):
     exiftool = ExiftoolRunner()
 
+    @classmethod
+    def add_format(cls, mime, ext, fn):
+        # Unfortunately there is no elegant way to extend Thumbor to support
+        # a new MIME type, which is why this monkey-patching is done here
+        from thumbor.utils import EXTENSION
+        EXTENSION[mime] = ext
+        from thumbor.engines import BaseEngine
+        old_get_mimetype = BaseEngine.get_mimetype
+
+        @classmethod
+        def new_get_mimetype(cls, buffer):
+            if fn(buffer):
+                return mime
+
+            return old_get_mimetype(buffer)
+
+        BaseEngine.get_mimetype = new_get_mimetype
+
     def create_image(self, buffer):
         # This should be enough for now, if memory blows up on huge files we
         # can could use an mmap here
@@ -396,3 +414,10 @@
 
     def debug(self, message):
         logger.debug(message, extra={'url': self.context.request.url})
+
+
+Engine.add_format(
+    'image/webp',
+    '.webp',
+    lambda buffer: buffer.startswith('RIFF') and buffer.startswith('WEBP', 8)
+)
diff --git a/wikimedia_thumbor/handler/images/images.py 
b/wikimedia_thumbor/handler/images/images.py
index e4a52b1..bdd81b0 100644
--- a/wikimedia_thumbor/handler/images/images.py
+++ b/wikimedia_thumbor/handler/images/images.py
@@ -419,6 +419,10 @@
             self.pc.close()
             self.pc = None
 
+        mc = self.failure_memcache()
+        if mc:
+            mc.disconnect_all()
+
         super(ImagesHandler, self).finish()
 
         self.context.metrics.incr('response.status.' + str(self.get_status()))

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5bcc3688b2caecc67030b775561e27bf1208342b
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/python-thumbor-wikimedia
Gerrit-Branch: master
Gerrit-Owner: Gilles <gdu...@wikimedia.org>

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

Reply via email to