mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Merge pull request #533 from wiredfool/fix_528
Fix for transparency = 0 in PNG mode P images
This commit is contained in:
commit
aa864f4ab4
|
@ -4,6 +4,9 @@ Changelog (Pillow)
|
|||
2.4.0 (unreleased)
|
||||
------------------
|
||||
|
||||
- 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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user