[Python-modules-commits] [thumbor] 02/04: Fixed some thumbor tests (Patch already applied by upstream)
Marcelo Jorge Vieira
metal at moszumanska.debian.org
Fri Nov 24 03:25:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
metal pushed a commit to branch master
in repository thumbor.
commit 0b1013901f138654be8ec275e3e0001584d5abde
Author: Marcelo Jorge Vieira <metal at alucinados.com>
Date: Fri Nov 24 00:27:45 2017 -0200
Fixed some thumbor tests (Patch already applied by upstream)
Tests:
* test_convert_tif_16bit_per_channel_lsb_to_png
* test_convert_tif_16bit_per_channel_msb_to_png
* test_convert_tif_8bit_per_channel_to_png
---
debian/patches/fix_convert_tif_to_png.patch | 53 +++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 54 insertions(+)
diff --git a/debian/patches/fix_convert_tif_to_png.patch b/debian/patches/fix_convert_tif_to_png.patch
new file mode 100644
index 0000000..954d593
--- /dev/null
+++ b/debian/patches/fix_convert_tif_to_png.patch
@@ -0,0 +1,53 @@
+--- a/tests/engines/test_pil.py
++++ b/tests/engines/test_pil.py
+@@ -121,7 +121,7 @@
+ engine = Engine(Context(config=cfg))
+ expect(engine.get_resize_filter()).to_equal(Image.LANCZOS)
+
+- @mock.patch('thumbor.engines.pil.cv', new=None)
++ @mock.patch('thumbor.engines.pil.cv2', new=None)
+ @mock.patch('thumbor.engines.logger.error')
+ def test_not_imported_cv2_failed_to_convert_tif_to_png(self, mockLogError):
+ engine = Engine(self.context)
+--- a/thumbor/engines/pil.py
++++ b/thumbor/engines/pil.py
+@@ -17,9 +17,11 @@
+ from PIL import Image, ImageFile, ImageDraw, ImageSequence, JpegImagePlugin
+
+ try:
+- from cv2 import cv
++ import cv2
++ import numpy
+ except:
+ cv = None
++ numpy = None
+
+ from thumbor.engines import BaseEngine
+ from thumbor.engines.extensions.pil import GifWriter
+@@ -289,19 +291,17 @@
+ return results
+
+ def convert_tif_to_png(self, buffer):
+- if not cv:
++ if not cv2:
++ msg = """[PILEngine] convert_tif_to_png failed: opencv not imported"""
++ logger.error(msg)
++ return buffer
++ if not numpy:
+ msg = """[PILEngine] convert_tif_to_png failed: opencv not imported"""
+ logger.error(msg)
+ return buffer
+
+- # can not use cv2 here, because ubuntu precise shipped with python-opencv 2.3 which has bug with imencode
+- # requires 3rd parameter buf which could not be created in python. Could be replaced with these lines:
+- # img = cv2.imdecode(numpy.fromstring(buffer, dtype='uint16'), -1)
+- # buffer = cv2.imencode('.png', img)[1].tostring()
+- mat_data = cv.CreateMatHeader(1, len(buffer), cv.CV_8UC1)
+- cv.SetData(mat_data, buffer, len(buffer))
+- img = cv.DecodeImage(mat_data, -1)
+- buffer = cv.EncodeImage(".png", img).tostring()
++ img = cv2.imdecode(numpy.fromstring(buffer, dtype='uint16'), -1)
++ buffer = cv2.imencode('.png', img)[1].tostring()
+
+ mime = self.get_mimetype(buffer)
+ self.extension = EXTENSION.get(mime, '.jpg')
diff --git a/debian/patches/series b/debian/patches/series
index 93a09bb..ac56f5b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
Fix-default-FILE_LOADER_ROOT_PATH
+fix_convert_tif_to_png.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/thumbor.git
More information about the Python-modules-commits
mailing list