Skip to content

Commit

Permalink
Merge branch 'saschwarz-gif-to-jpeg'
Browse files Browse the repository at this point in the history
  • Loading branch information
agschwender committed Oct 22, 2017
2 parents 28f75b4 + f15a682 commit 39bcf6b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@
* 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
* 1.3.1: Fix pilbox.image CLI for python 3.0
* 1.3.2: Fix GIF P-mode to JPEG conversion
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,5 @@ Changelog
- 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
- 1.3.1: Fix pilbox.image CLI for python 3.0
- 1.3.2: Fix GIF P-mode to JPEG conversion
6 changes: 4 additions & 2 deletions pilbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@
* 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
* 1.3.1: Fix pilbox.image CLI for python 3.0
* 1.3.2: Fix GIF P-mode to JPEG conversion
"""

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

# 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, 0, 0)
version_info = (1, 3, 2, 0)
6 changes: 6 additions & 0 deletions pilbox/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ def save(self, **kwargs):
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")

try:
self.img.save(outfile, fmt, **save_kwargs)
except IOError as e:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pilbox/test/data/test-p-mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pilbox/test/image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def get_image_resize_cases():
cases.append(_criteria_to_resize_case(
"test space.jpg", _get_simple_criteria_combinations()[0]))

cases.append(_criteria_to_resize_case(
"test-p-mode.gif", dict(width=100, height=100, format='jpeg', mode='crop')))

for criteria in _get_advanced_criteria_combinations():
cases.append(_criteria_to_resize_case("test-advanced.jpg", criteria))

Expand Down
2 changes: 1 addition & 1 deletion 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.0',
version='1.3.2',
description='Pilbox is an image processing application server built on the Tornado web framework using the Pillow Imaging Library',
long_description=readme,
classifiers=[
Expand Down

0 comments on commit 39bcf6b

Please sign in to comment.