From c93f990111351ffbc000f0cceeb8b04898387dd7 Mon Sep 17 00:00:00 2001 From: Adam Gschwender Date: Thu, 20 Apr 2017 16:28:19 -0400 Subject: [PATCH] Upgrade Pillow and Tornado --- .travis.yml | 2 +- CHANGES.txt | 1 + README.rst | 7 ++++--- pilbox/__init__.py | 5 +++-- pilbox/image.py | 15 ++++++++++++--- .../data/expected/test5-100x200-mode=clip.gif | Bin 7955 -> 7955 bytes .../expected/test5-100x200-mode=scale.gif | Bin 23142 -> 23142 bytes .../data/expected/test5-300x300-mode=clip.gif | Bin 65004 -> 65004 bytes .../expected/test5-300x300-mode=scale.gif | Bin 99969 -> 99969 bytes .../data/expected/test5-400x300-mode=clip.gif | Bin 113729 -> 113729 bytes .../expected/test5-400x300-mode=scale.gif | Bin 132118 -> 132118 bytes provisioning/playbook.yml | 4 ++-- setup.py | 6 +++--- 13 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2a783d..5ee7806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_install: - sudo apt-get install python-numpy python-opencv python-pycurl install: - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi - - pip install tornado==4.0.2 Pillow==2.8.1 coveralls + - pip install tornado==4.5.1 Pillow==2.9.0 coveralls - pip install pep8==1.6.2 pyflakes==0.8.1 before_script: - pep8 --exclude=test pilbox diff --git a/CHANGES.txt b/CHANGES.txt index cd69600..c2d482a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -54,3 +54,4 @@ * 1.2.1: Added max operations config property * 1.2.2: Added max resize width and height config properties * 1.2.3: Added user_agent option + * 1.3.0: Increased Pillow to 4.1.0 and Tornado to 4.5.1 diff --git a/README.rst b/README.rst index 561318b..8bc769f 100644 --- a/README.rst +++ b/README.rst @@ -31,9 +31,9 @@ Setup Dependencies ------------ -- >= `Python 2.7 `_ -- `Pillow 2.8.1 `_ -- `Tornado 4.0.2 `_ +- `Python >= 2.7 `_ +- `Pillow 4.1.0 `_ +- `Tornado 2.9.0 `_ - `OpenCV 2.x `_ (optional) - `PycURL 7.x `_ (optional, but recommended; required for proxy requests and requests over TLS) @@ -631,3 +631,4 @@ Changelog - 1.2.1: Added max operations config property - 1.2.2: Added max resize width and height config properties - 1.2.3: Added user_agent option +- 1.3.0: Increased Pillow to 2.9.0 and Tornado to 4.5.1 diff --git a/pilbox/__init__.py b/pilbox/__init__.py index ff17144..f51c1c7 100644 --- a/pilbox/__init__.py +++ b/pilbox/__init__.py @@ -77,13 +77,14 @@ * 1.2.1: Added max operations config property * 1.2.2: Added max resize width and height config properties * 1.2.3: Added user_agent option + * 1.3.0: Increased Pillow to 2.9.0 and Tornado to 4.5.1 """ # human-readable version number -version = "1.2.3" +version = "1.3.0" # The first three numbers are the components of the version number. # The fourth is zero for an official release, positive for a development # branch, or negative for a release candidate or beta (after the base version # number has been incremented) -version_info = (1, 2, 3, 0) +version_info = (1, 3, 0, 0) diff --git a/pilbox/image.py b/pilbox/image.py index 47fa307..6c86edc 100644 --- a/pilbox/image.py +++ b/pilbox/image.py @@ -224,8 +224,17 @@ def rotate(self, deg, **kwargs): else: deg = 0 - expand = False if int(deg) % 90 == 0 else bool(int(opts["expand"])) - self.img = self.img.rotate(360 - int(deg), expand=expand) + deg = 360 - (int(deg) % 360) + if deg % 90 == 0: + if deg == 90: + self.img = self.img.transpose(PIL.Image.ROTATE_90) + elif deg == 180: + self.img = self.img.transpose(PIL.Image.ROTATE_180) + elif deg == 270: + self.img = self.img.transpose(PIL.Image.ROTATE_270) + else: + self.img = self.img.rotate(deg, expand=bool(int(opts["expand"]))) + return self def save(self, **kwargs): @@ -376,7 +385,7 @@ def _get_face_classifier(self): def _pil_to_opencv(self): mono = self.img.convert("L") cvim = cv.CreateImageHeader(mono.size, cv.IPL_DEPTH_8U, 1) - cv.SetData(cvim, mono.tostring(), mono.size[0]) + cv.SetData(cvim, mono.tobytes(), mono.size[0]) cv.EqualizeHist(cvim, cvim) return cvim diff --git a/pilbox/test/data/expected/test5-100x200-mode=clip.gif b/pilbox/test/data/expected/test5-100x200-mode=clip.gif index 5675b7581558a1ae6d0f9ab7997d1a641032ae29..4e3d2e36d936216bf069e4724b69f73ee89c0e28 100644 GIT binary patch delta 21 ccmbPiH`$KI-P6s&JTZmAfuX%^BM-Yg07di#=>Px# delta 21 ccmbPiH`$KI-P6s&JTZmAfuWsYBM-Yg07F&Ie-0 diff --git a/pilbox/test/data/expected/test5-300x300-mode=clip.gif b/pilbox/test/data/expected/test5-300x300-mode=clip.gif index 55890bf8cb55cc4c2f031efbe563ee012017e9ef..51ca7d82f184c5cc99178c7725e43cc504d04389 100644 GIT binary patch delta 23 fcmaF!oB7ReW*&D>Hw*Jb9mYcp?QI)*9{dFWdXEYn delta 23 fcmaF!oB7ReW*&D>Hw*Jb9mYcp?F<`v9{dFWckv0A diff --git a/pilbox/test/data/expected/test5-300x300-mode=scale.gif b/pilbox/test/data/expected/test5-300x300-mode=scale.gif index 193445efeefaf7d41bdbb7b5702ffe0f40541140..5d8bdaeae952e2b38e65becb2ff0e28d0c66582f 100644 GIT binary patch delta 26 hcmZqdWoztZ<8k+NvoKH8Vbo!4Z)@b)%EMUN1^{K?2aEs! delta 26 hcmZqdWoztZ<8k+NvoKH8Vbo!4XK3Wv%EMUN1^{8O2L=ED diff --git a/pilbox/test/data/expected/test5-400x300-mode=clip.gif b/pilbox/test/data/expected/test5-400x300-mode=clip.gif index c3eaa2164a786186c2f354bfabb4e86157f1701d..8fcbcc8aed0d89784063c58f05a12e534900208e 100644 GIT binary patch delta 26 icmX^3gYDoCHXe6RHw*K`35-mP?QM-bTX`5w_W%Hh!3h!o delta 26 icmX^3gYDoCHXe6RHw*K`35-mP?F@}PTX`5w_W%HdkqC?c diff --git a/pilbox/test/data/expected/test5-400x300-mode=scale.gif b/pilbox/test/data/expected/test5-400x300-mode=scale.gif index 0335695c7ddfdb1e8741d5641bc60675d890c76e..89ae77ee03d0bf0fdaaa370fda6c60349590150b 100644 GIT binary patch delta 29 kcmbQ%!7;6agU8*|&B8o!0;3LNds`z