diff --git a/CHANGES.txt b/CHANGES.txt index c2d482a..13c3e38 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/README.rst b/README.rst index 3d50c3e..b255d0d 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/pilbox/__init__.py b/pilbox/__init__.py index f51c1c7..c1eedee 100644 --- a/pilbox/__init__.py +++ b/pilbox/__init__.py @@ -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) diff --git a/pilbox/image.py b/pilbox/image.py index c23ff54..bb23846 100644 --- a/pilbox/image.py +++ b/pilbox/image.py @@ -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: diff --git a/pilbox/test/data/expected/test-p-mode-100x100-mode=crop.jpeg b/pilbox/test/data/expected/test-p-mode-100x100-mode=crop.jpeg new file mode 100644 index 0000000..8101f97 Binary files /dev/null and b/pilbox/test/data/expected/test-p-mode-100x100-mode=crop.jpeg differ diff --git a/pilbox/test/data/test-p-mode.gif b/pilbox/test/data/test-p-mode.gif new file mode 100644 index 0000000..c895d7e Binary files /dev/null and b/pilbox/test/data/test-p-mode.gif differ diff --git a/pilbox/test/image_test.py b/pilbox/test/image_test.py index 08a91b7..72fb4c9 100644 --- a/pilbox/test/image_test.py +++ b/pilbox/test/image_test.py @@ -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)) diff --git a/setup.py b/setup.py index 26f16cd..bb180da 100644 --- a/setup.py +++ b/setup.py @@ -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=[