Skip to content

Commit

Permalink
Merge 58d0d34 into 5b39bd4
Browse files Browse the repository at this point in the history
  • Loading branch information
agschwender committed Jul 27, 2018
2 parents 5b39bd4 + 58d0d34 commit 90fe16e
Show file tree
Hide file tree
Showing 213 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ before_install:
- sudo apt-get install libwebp-dev liblcms2-dev
- sudo apt-get install python-numpy python-opencv python-pycurl
install:
- pip install tornado==4.5.1 Pillow==2.9.0 coveralls
- pip install tornado==5.1.0 Pillow==5.2.0 coveralls
- pip install pep8==1.6.2 pyflakes==0.8.1
before_script:
- pep8 --exclude=test pilbox
Expand Down
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@
* 1.3.0: Increased Pillow to 4.1.0 and Tornado to 4.5.1
* 1.3.1: Fix pilbox.image CLI for python 3.0
* 1.3.2: Fix GIF P-mode to JPEG conversion
* 1.3.3: Increase Pillow version to 5.2.0 and Tornado version to 5.1.0
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,4 @@ Changelog
- 1.3.0: Increased Pillow to 2.9.0 and Tornado to 4.5.1
- 1.3.1: Fix pilbox.image CLI for python 3.0
- 1.3.2: Fix GIF P-mode to JPEG conversion
- 1.3.3: Increase Pillow version to 5.2.0 and Tornado version to 5.1.0
5 changes: 3 additions & 2 deletions pilbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@
* 1.3.0: Increased Pillow to 2.9.0 and Tornado to 4.5.1
* 1.3.1: Fix pilbox.image CLI for python 3.0
* 1.3.2: Fix GIF P-mode to JPEG conversion
* 1.3.3: Increase Pillow version to 5.2.0 and Tornado version to 5.1.0
"""

# human-readable version number
version = "1.3.2"
version = "1.3.3"

# 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, 3, 2, 0)
version_info = (1, 3, 3, 0)
18 changes: 11 additions & 7 deletions pilbox/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,21 @@ def save(self, **kwargs):
if self.img.mode == "RGBA":
self._background(fmt, color)

if self._orig_format == "JPEG":
self.img.format = self._orig_format
if self.img.format == "JPEG":
save_kwargs["subsampling"] = "keep"
if opts["quality"] == "keep":
save_kwargs["quality"] = "keep"

if fmt == "JPEG" and self.img.mode == 'P':
# Converting old GIF and PNG files to JPEG can raise
# IOError: cannot write mode P as JPEG
# https://mail.python.org/pipermail/python-list/2000-May/036017.html
self.img = self.img.convert("RGB")
if fmt == "JPEG":
if self.img.mode == "P":
# Converting old GIF and PNG files to JPEG can raise
# IOError: cannot write mode P as JPEG
# https://mail.python.org/pipermail/python-list/2000-May/036017.html
self.img = self.img.convert("RGB")
elif self.img.mode == "RGBA":
# JPEG does not have an alpha channel so cannot be
# saved as RGBA. It must be converted to RGB.
self.img = self.img.convert("RGB")

try:
self.img.save(outfile, fmt, **save_kwargs)
Expand Down
11 changes: 4 additions & 7 deletions pilbox/test/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,14 @@ def get_handlers(self):

class _DelayedHandler(tornado.web.RequestHandler):

@tornado.web.asynchronous
@tornado.gen.coroutine
def get(self):
delay = time.time() + float(self.get_argument("delay", 0.0))
yield tornado.gen.Task(
tornado.ioloop.IOLoop.instance().add_timeout, delay)
yield tornado.gen.sleep(float(self.get_argument("delay", 0.0)))
self.finish()


class _UserAgentHandler(tornado.web.RequestHandler):

@tornado.web.asynchronous
def get(self):
ua = self.request.headers.get("User-Agent", "")
expected_ua = self.get_argument("ua", "")
Expand All @@ -189,7 +186,7 @@ def get(self):

self.set_status(200)
self.set_header("Content-Type", "image/jpeg")
img = PIL.Image.new('RGBA', (1, 1))
img = PIL.Image.new('RGB', (1, 1))
outfile = BytesIO()
img.save(outfile, "JPEG")
outfile.seek(0)
Expand Down Expand Up @@ -528,7 +525,7 @@ def get_app(self):
return _PilboxTestApplication(
client_name=self.NAME,
client_key=self.KEY,
allowed_hosts=["foo.co", "bar.io", "localhost"],
allowed_hosts=["foo.co", "bar.io", "localhost", "127.0.0.1"],
timeout=10.0)

def test_missing_client_name(self):
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/example-500x400-mode=adapt-retain=80.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/example-500x400-mode=clip.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/example-500x400-mode=crop.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/example-500x400-mode=scale.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test space-400x300-mode=adapt.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x-mode=adapt.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x-mode=clip.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x-mode=crop.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x-mode=fill.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x-mode=scale.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.gif
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.jpeg
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.png
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.tiff
Binary file not shown.
Binary file modified pilbox/test/data/expected/test-advanced-125x75-mode=crop.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test-advanced-x125-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test-advanced-x125-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test-advanced-x125-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test-advanced-x125-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test-advanced-x125-mode=scale.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pilbox/test/data/expected/test-bad-exif-rotate-degree=auto.jpg
Binary file modified pilbox/test/data/expected/test-orientation-exif-preserve_exif=0.jpg
Binary file modified pilbox/test/data/expected/test-orientation-exif-preserve_exif=1.jpg
Binary file modified pilbox/test/data/expected/test-p-mode-100x100-mode=crop.jpeg
Binary file modified pilbox/test/data/expected/test1-100x200-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test1-100x200-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test1-100x200-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test1-100x200-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test1-100x200-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test1-300x300-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test1-300x300-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test1-300x300-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test1-300x300-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test1-300x300-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test1-400x300-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test1-400x300-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test1-400x300-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test1-400x300-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test1-400x300-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test1-region-rect=150,150,100,100.jpg
Binary file modified pilbox/test/data/expected/test1-region-rect=200,175,50,50.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=180-expand=1.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=180.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=315-expand=1.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=315.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=90-expand=1.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=90.jpg
Binary file modified pilbox/test/data/expected/test1-rotate-degree=auto.jpg
Binary file modified pilbox/test/data/expected/test2-100x200-mode=adapt.png
Binary file modified pilbox/test/data/expected/test2-100x200-mode=clip.png
Binary file modified pilbox/test/data/expected/test2-100x200-mode=crop.png
Binary file modified pilbox/test/data/expected/test2-100x200-mode=fill.png
Binary file modified pilbox/test/data/expected/test2-100x200-mode=scale.png
Binary file modified pilbox/test/data/expected/test2-300x300-mode=adapt.png
Binary file modified pilbox/test/data/expected/test2-300x300-mode=clip.png
Binary file modified pilbox/test/data/expected/test2-300x300-mode=crop.png
Binary file modified pilbox/test/data/expected/test2-300x300-mode=fill.png
Binary file modified pilbox/test/data/expected/test2-300x300-mode=scale.png
Binary file modified pilbox/test/data/expected/test2-400x300-mode=adapt.png
Binary file modified pilbox/test/data/expected/test2-400x300-mode=clip.png
Binary file modified pilbox/test/data/expected/test2-400x300-mode=fill.png
Binary file modified pilbox/test/data/expected/test2-400x300-mode=scale.png
Binary file modified pilbox/test/data/expected/test3-100x200-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test3-100x200-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test3-100x200-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test3-100x200-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test3-100x200-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test3-300x300-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test3-300x300-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test3-300x300-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test3-300x300-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test3-300x300-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test3-400x300-mode=adapt.jpg
Binary file modified pilbox/test/data/expected/test3-400x300-mode=clip.jpg
Binary file modified pilbox/test/data/expected/test3-400x300-mode=crop.jpg
Binary file modified pilbox/test/data/expected/test3-400x300-mode=fill.jpg
Binary file modified pilbox/test/data/expected/test3-400x300-mode=scale.jpg
Binary file modified pilbox/test/data/expected/test4-100x200-mode=adapt.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-100x200-mode=clip.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-100x200-mode=crop.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-100x200-mode=fill.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-100x200-mode=scale.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-300x300-mode=adapt.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-300x300-mode=clip.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-300x300-mode=crop.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-300x300-mode=fill.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-300x300-mode=scale.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-400x300-mode=adapt.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-400x300-mode=clip.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-400x300-mode=crop.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-400x300-mode=fill.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test4-400x300-mode=scale.webp
Binary file not shown.
Binary file modified pilbox/test/data/expected/test5-100x200-mode=adapt.gif
Binary file modified pilbox/test/data/expected/test5-100x200-mode=clip.gif
Binary file modified pilbox/test/data/expected/test5-100x200-mode=crop.gif
Binary file modified pilbox/test/data/expected/test5-100x200-mode=fill.gif
Binary file modified pilbox/test/data/expected/test5-100x200-mode=scale.gif
Binary file modified pilbox/test/data/expected/test5-300x300-mode=adapt.gif
Binary file modified pilbox/test/data/expected/test5-300x300-mode=clip.gif
Binary file modified pilbox/test/data/expected/test5-300x300-mode=crop.gif
Binary file modified pilbox/test/data/expected/test5-300x300-mode=fill.gif
Binary file modified pilbox/test/data/expected/test5-300x300-mode=scale.gif
Binary file modified pilbox/test/data/expected/test5-400x300-mode=adapt.gif
Binary file modified pilbox/test/data/expected/test5-400x300-mode=clip.gif
Binary file modified pilbox/test/data/expected/test5-400x300-mode=crop.gif
Binary file modified pilbox/test/data/expected/test5-400x300-mode=fill.gif
Binary file modified pilbox/test/data/expected/test5-400x300-mode=scale.gif
Binary file modified pilbox/test/data/expected/test6-100x200-mode=adapt.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-100x200-mode=clip.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-100x200-mode=crop.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-100x200-mode=fill.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-100x200-mode=scale.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-300x300-mode=adapt.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-300x300-mode=clip.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-300x300-mode=crop.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-300x300-mode=fill.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-300x300-mode=scale.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-400x300-mode=adapt.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-400x300-mode=clip.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-400x300-mode=crop.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-400x300-mode=fill.tif
Binary file not shown.
Binary file modified pilbox/test/data/expected/test6-400x300-mode=scale.tif
Binary file not shown.
4 changes: 4 additions & 0 deletions pilbox/test/image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pilbox import errors
from pilbox.image import color_hex_to_dec_tuple, Image


try:
import cv
except ImportError:
Expand Down Expand Up @@ -321,6 +322,9 @@ def test_invalid_color_hex_to_dec_tuple(self):

def test_save_failure(self):
img = Image(os.path.join(DATADIR, 'test5.gif'))
def _mock_save(*args, **kwargs):
raise IOError('foo')
img.img.save = _mock_save
self.assertRaises(errors.ImageSaveError,
lambda: img.save(format="webp"))

Expand Down
4 changes: 2 additions & 2 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
version={{ item.version }}
use_mirrors=yes
with_items:
- { name: 'Pillow', version: '2.9.0' }
- { name: 'tornado', version: '4.5.1' }
- { name: 'Pillow', version: '5.2.0' }
- { name: 'tornado', version: '5.1.0' }
- { name: 'coverage', version: '3.6' }
- { name: 'pep8', version: '1.6.2' }
- { name: 'pyflakes', version: '0.8.1' }
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run(self):


setup(name='pilbox',
version='1.3.2',
version='1.3.3',
description='Pilbox is an image processing application server built on the Tornado web framework using the Pillow Imaging Library',
long_description=readme,
classifiers=[
Expand All @@ -43,8 +43,8 @@ def run(self):
'pilbox': ['frontalface.xml'],
},
install_requires=[
'tornado==4.5.1',
'Pillow==2.9.0',
'tornado==5.1.0',
'Pillow==5.2.0',
'sphinx-me==0.2.1',
],
extras_require = {
Expand Down

0 comments on commit 90fe16e

Please sign in to comment.