Merge branch 'ellipse' of github.com:xtsm/Pillow into ellipse

This commit is contained in:
Stanislau Tsitsianok 2020-05-08 23:17:24 +03:00
commit 4fe8f5fdad
No known key found for this signature in database
GPG Key ID: 349CB26B2ED6E0C0
6 changed files with 16 additions and 18 deletions

View File

@ -7,6 +7,7 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\
ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\ ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\
cmake imagemagick libharfbuzz-dev libfribidi-dev cmake imagemagick libharfbuzz-dev libfribidi-dev
pip install --upgrade pip
PYTHONOPTIMIZE=0 pip install cffi PYTHONOPTIMIZE=0 pip install cffi
pip install coverage pip install coverage
pip install olefile pip install olefile
@ -20,7 +21,7 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.* ]]; then
# "ERROR: Could not find a version that satisfies the requirement pyqt5" # "ERROR: Could not find a version that satisfies the requirement pyqt5"
if [[ $TRAVIS_CPU_ARCH == "amd64" ]]; then if [[ $TRAVIS_CPU_ARCH == "amd64" ]]; then
sudo apt-get -qq install pyqt5-dev-tools sudo apt-get -qq install pyqt5-dev-tools
pip install pyqt5!=5.14.1 pip install pyqt5
fi fi
fi fi

View File

@ -637,6 +637,9 @@ class TestFilePng:
with Image.open(TEST_PNG_FILE) as im: with Image.open(TEST_PNG_FILE) as im:
im.seek(0) im.seek(0)
with pytest.raises(EOFError):
im.seek(1)
@pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS") @pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS")
@skip_unless_feature("zlib") @skip_unless_feature("zlib")

View File

@ -293,8 +293,11 @@ def test_ellipse_edge():
def test_ellipse_symmetric(): def test_ellipse_symmetric():
for bbox in [(24, 25, 76, 75), (25, 25, 75, 75), (25, 24, 75, 76)]: for width, bbox in (
im = Image.new("RGB", (101, 101)) (100, (24, 24, 75, 75)),
(101, (25, 25, 75, 75)),
):
im = Image.new("RGB", (width, 100))
draw = ImageDraw.Draw(im) draw = ImageDraw.Draw(im)
draw.ellipse(bbox, fill="green", outline="blue") draw.ellipse(bbox, fill="green", outline="blue")
assert_image_equal(im, im.transpose(Image.FLIP_LEFT_RIGHT)) assert_image_equal(im, im.transpose(Image.FLIP_LEFT_RIGHT))

View File

@ -229,7 +229,7 @@ Plugin reference
---------------------------- ----------------------------
.. automodule:: PIL.PngImagePlugin .. automodule:: PIL.PngImagePlugin
:members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk :members: ChunkStream, PngStream, getchunks, is_cid, putchunk
:show-inheritance: :show-inheritance:
.. autoclass:: PIL.PngImagePlugin.ChunkStream .. autoclass:: PIL.PngImagePlugin.ChunkStream
:members: :members:

View File

@ -673,7 +673,7 @@ class PngImageFile(ImageFile.ImageFile):
self._text = None self._text = None
self.tile = self.png.im_tile self.tile = self.png.im_tile
self.custom_mimetype = self.png.im_custom_mimetype self.custom_mimetype = self.png.im_custom_mimetype
self._n_frames = self.png.im_n_frames self.n_frames = self.png.im_n_frames or 1
self.default_image = self.info.get("default_image", False) self.default_image = self.info.get("default_image", False)
if self.png.im_palette: if self.png.im_palette:
@ -685,15 +685,16 @@ class PngImageFile(ImageFile.ImageFile):
else: else:
self.__prepare_idat = length # used by load_prepare() self.__prepare_idat = length # used by load_prepare()
if self._n_frames is not None: if self.png.im_n_frames is not None:
self._close_exclusive_fp_after_loading = False self._close_exclusive_fp_after_loading = False
self.png.save_rewind() self.png.save_rewind()
self.__rewind_idat = self.__prepare_idat self.__rewind_idat = self.__prepare_idat
self.__rewind = self.__fp.tell() self.__rewind = self.__fp.tell()
if self.default_image: if self.default_image:
# IDAT chunk contains default image and not first animation frame # IDAT chunk contains default image and not first animation frame
self._n_frames += 1 self.n_frames += 1
self._seek(0) self._seek(0)
self.is_animated = self.n_frames > 1
@property @property
def text(self): def text(self):
@ -710,16 +711,6 @@ class PngImageFile(ImageFile.ImageFile):
self.seek(frame) self.seek(frame)
return self._text return self._text
@property
def n_frames(self):
if self._n_frames is None:
return 1
return self._n_frames
@property
def is_animated(self):
return self._n_frames is not None and self._n_frames > 1
def verify(self): def verify(self):
"""Verify PNG file""" """Verify PNG file"""

View File

@ -1039,7 +1039,7 @@ int8_t quarter_next(quarter_state* s, int32_t* ret_x, int32_t* ret_y) {
// quarter_* stuff can "draw" a quarter of an ellipse with thickness 1, great. // quarter_* stuff can "draw" a quarter of an ellipse with thickness 1, great.
// Now we use ellipse_* stuff to join all four quarters of two different sized // Now we use ellipse_* stuff to join all four quarters of two different sized
// ellipses and recieve horizontal segments of a complete ellipse with // ellipses and receive horizontal segments of a complete ellipse with
// specified thickness. // specified thickness.
// //
// Still using integer grid with step 2 at this point (like in quarter_*) // Still using integer grid with step 2 at this point (like in quarter_*)