Merge Changes from Master

This commit is contained in:
wiredfool 2014-03-04 22:43:19 -08:00
commit 414e887726
7 changed files with 59 additions and 7 deletions

View File

@ -1,12 +1,18 @@
Changelog (Pillow)
==================
2.4.0 (2014-04-01 est.)
2.4.0 (unreleased)
------------------
- Fixed opening and saving odd sized .pcx files
[wiredfool]
- Fixed saving mode P image as a PNG with transparency = palette color 0
[d-schmidt]
- Improve heuristic used when saving progressive and optimized JPEGs with high quality values
[e98cuenc]
- Fixed DOS with invalid palette size or invalid image size in BMP file
[wiredfool]

View File

@ -1098,7 +1098,6 @@ class Image:
third, the box defaults to (0, 0), and the second argument
is interpreted as a mask image.
:param mask: An optional mask image.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
if isImageType(box) and mask is None:

View File

@ -566,6 +566,9 @@ def _save(im, fp, filename):
# https://github.com/jdriscoll/django-imagekit/issues/50
bufsize=0
if "optimize" in info or "progressive" in info or "progression" in info:
if quality >= 95:
bufsize = 2 * im.size[0] * im.size[1]
else:
bufsize = im.size[0] * im.size[1]
# The exif info needs to be written as one block, + APP1, + one spare byte.

View File

@ -561,7 +561,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0):
transparency = im.encoderinfo.get('transparency',im.info.get('transparency', None))
if transparency:
if transparency or transparency == 0:
if im.mode == "P":
# limit to actual palette size
alpha_bytes = 2**bits

View File

@ -1,5 +1,7 @@
from tester import *
import random
from PIL import Image
from PIL import ImageFile
@ -132,13 +134,23 @@ def test_progressive_large_buffer():
im = Image.new("RGB", (4096,4096), 0xff3333)
im.save(f, format="JPEG", progressive=True)
def test_progressive_large_buffer_highest_quality():
f = tempfile('temp.jpg')
if py3:
a = bytes(random.randint(0, 255) for _ in range(256 * 256 * 3))
else:
a = b''.join(chr(random.randint(0, 255)) for _ in range(256 * 256 * 3))
im = Image.frombuffer("RGB", (256, 256), a, "raw", "RGB", 0, 1)
# this requires more bytes than pixels in the image
im.save(f, format="JPEG", progressive=True, quality=100)
def test_large_exif():
#https://github.com/python-imaging/Pillow/issues/148
f = tempfile('temp.jpg')
im = lena()
im.save(f,'JPEG', quality=90, exif=b"1"*65532)
def test_progressive():
def test_progressive_compat():
im1 = roundtrip(lena())
im2 = roundtrip(lena(), progressive=1)
im3 = roundtrip(lena(), progression=1) # compatibility

View File

@ -251,6 +251,20 @@ def test_trns_rgb():
im = roundtrip(im, transparency=(0, 1, 2))
assert_equal(im.info["transparency"], (0, 1, 2))
def test_trns_p():
# Check writing a transparency of 0, issue #528
im = lena('P')
im.info['transparency']=0
f = tempfile("temp.png")
im.save(f)
im2 = Image.open(f)
assert_true('transparency' in im2.info)
assert_image_equal(im2.convert('RGBA'), im.convert('RGBA'))
def test_save_icc_profile_none():
# check saving files with an ICC profile set to None (omit profile)
in_file = "Tests/images/icc_profile_none.png"

View File

@ -16,6 +16,24 @@ The fork authors' goal is to foster active development of PIL through:
.. _Python Package Index: https://pypi.python.org/pypi/Pillow
.. _Image-SIG: http://mail.python.org/mailman/listinfo/image-sig
License
-------
like PIL itself, Pillow is licensed under the MIT-like `PIL Software License <http://www.pythonware.com/products/pil/license.htm>`::
Software License
The Python Imaging Library (PIL) is
Copyright © 1997-2011 by Secret Labs AB
Copyright © 1995-2011 by Fredrik Lundh
By obtaining, using, and/or copying this software and/or its associated documentation, you agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, modify, and distribute this software and its associated documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies, and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Secret Labs AB or the author not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Why a fork?
-----------
@ -26,8 +44,8 @@ issues reported.
.. _this Image-SIG post: https://mail.python.org/pipermail/image-sig/2010-August/006480.html
What about the official PIL?
----------------------------
What about PIL?
---------------
.. note::