mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Merge branch 'master' into expand
This commit is contained in:
commit
02d92a594c
|
@ -5,6 +5,12 @@ Changelog (Pillow)
|
|||
8.4.0 (unreleased)
|
||||
------------------
|
||||
|
||||
- Catch TypeError from corrupted DPI value in EXIF #5639
|
||||
[homm, radarhere]
|
||||
|
||||
- Do not close file pointer when saving SGI images #5645
|
||||
[farizrahman4u, radarhere]
|
||||
|
||||
- Deprecate ImagePalette size parameter #5641
|
||||
[radarhere, hugovk]
|
||||
|
||||
|
|
BIN
Tests/images/broken_exif_dpi.jpg
Normal file
BIN
Tests/images/broken_exif_dpi.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
|
@ -718,6 +718,15 @@ class TestFileJpeg:
|
|||
# This should return the default, and not raise a ZeroDivisionError
|
||||
assert im.info.get("dpi") == (72, 72)
|
||||
|
||||
def test_dpi_exif_string(self):
|
||||
# Arrange
|
||||
# 0x011A tag in this exif contains string '300300\x02'
|
||||
with Image.open("Tests/images/broken_exif_dpi.jpg") as im:
|
||||
|
||||
# Act / Assert
|
||||
# This should return the default
|
||||
assert im.info.get("dpi") == (72, 72)
|
||||
|
||||
def test_no_dpi_in_exif(self):
|
||||
# Arrange
|
||||
# This is photoshop-200dpi.jpg with resolution removed from EXIF:
|
||||
|
|
|
@ -73,6 +73,13 @@ def test_write(tmp_path):
|
|||
img.save(out, format="sgi")
|
||||
assert_image_equal_tofile(img, out)
|
||||
|
||||
out = str(tmp_path / "fp.sgi")
|
||||
with open(out, "wb") as fp:
|
||||
img.save(fp)
|
||||
assert_image_equal_tofile(img, out)
|
||||
|
||||
assert not fp.closed
|
||||
|
||||
for mode in ("L", "RGB", "RGBA"):
|
||||
roundtrip(hopper(mode))
|
||||
|
||||
|
|
41
docs/releasenotes/8.4.0.rst
Normal file
41
docs/releasenotes/8.4.0.rst
Normal file
|
@ -0,0 +1,41 @@
|
|||
8.4.0
|
||||
-----
|
||||
|
||||
API Changes
|
||||
===========
|
||||
|
||||
Deprecations
|
||||
^^^^^^^^^^^^
|
||||
|
||||
ImagePalette size parameter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``size`` parameter will be removed in Pillow 10.0.0 (2023-01-02).
|
||||
|
||||
Before Pillow 8.3.0, ``ImagePalette`` required palette data of particular lengths by
|
||||
default, and the size parameter could be used to override that. Pillow 8.3.0 removed
|
||||
the default required length, also removing the need for the size parameter.
|
||||
|
||||
API Additions
|
||||
=============
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
|
||||
TODO
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
|
||||
TODO
|
||||
|
||||
Other Changes
|
||||
=============
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
|
||||
TODO
|
|
@ -14,6 +14,7 @@ expected to be backported to earlier versions.
|
|||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
8.4.0
|
||||
8.3.1
|
||||
8.3.0
|
||||
8.2.0
|
||||
|
|
|
@ -168,11 +168,11 @@ def APP(self, marker):
|
|||
# 1 dpcm = 2.54 dpi
|
||||
dpi *= 2.54
|
||||
self.info["dpi"] = dpi, dpi
|
||||
except (KeyError, SyntaxError, ValueError, ZeroDivisionError):
|
||||
except (TypeError, KeyError, SyntaxError, ValueError, ZeroDivisionError):
|
||||
# SyntaxError for invalid/unreadable EXIF
|
||||
# KeyError for dpi not included
|
||||
# ZeroDivisionError for invalid dpi rational value
|
||||
# ValueError for dpi being an invalid float
|
||||
# ValueError or TypeError for dpi being an invalid float
|
||||
self.info["dpi"] = 72, 72
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ def _save(im, fp, filename):
|
|||
for channel in im.split():
|
||||
fp.write(channel.tobytes("raw", rawmode, 0, orientation))
|
||||
|
||||
fp.close()
|
||||
if hasattr(fp, "flush"):
|
||||
fp.flush()
|
||||
|
||||
|
||||
class SGI16Decoder(ImageFile.PyDecoder):
|
||||
|
|
Loading…
Reference in New Issue
Block a user