diff --git a/.ci/install.sh b/.ci/install.sh index 8e819631a..180fa6582 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -7,6 +7,7 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\ ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\ cmake imagemagick libharfbuzz-dev libfribidi-dev +pip install --upgrade pip PYTHONOPTIMIZE=0 pip install cffi pip install coverage pip install olefile @@ -20,7 +21,7 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.* ]]; then # "ERROR: Could not find a version that satisfies the requirement pyqt5" if [[ $TRAVIS_CPU_ARCH == "amd64" ]]; then sudo apt-get -qq install pyqt5-dev-tools - pip install pyqt5!=5.14.1 + pip install pyqt5 fi fi diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 469d186e8..476995dd7 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -637,6 +637,9 @@ class TestFilePng: with Image.open(TEST_PNG_FILE) as im: im.seek(0) + with pytest.raises(EOFError): + im.seek(1) + @pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS") @skip_unless_feature("zlib") diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index cc29c097e..7a900283e 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -293,8 +293,11 @@ def test_ellipse_edge(): def test_ellipse_symmetric(): - for bbox in [(24, 25, 76, 75), (25, 25, 75, 75), (25, 24, 75, 76)]: - im = Image.new("RGB", (101, 101)) + for width, bbox in ( + (100, (24, 24, 75, 75)), + (101, (25, 25, 75, 75)), + ): + im = Image.new("RGB", (width, 100)) draw = ImageDraw.Draw(im) draw.ellipse(bbox, fill="green", outline="blue") assert_image_equal(im, im.transpose(Image.FLIP_LEFT_RIGHT)) diff --git a/docs/reference/plugins.rst b/docs/reference/plugins.rst index 46f657fce..cc0742fde 100644 --- a/docs/reference/plugins.rst +++ b/docs/reference/plugins.rst @@ -229,7 +229,7 @@ Plugin reference ---------------------------- .. automodule:: PIL.PngImagePlugin - :members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk + :members: ChunkStream, PngStream, getchunks, is_cid, putchunk :show-inheritance: .. autoclass:: PIL.PngImagePlugin.ChunkStream :members: diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 0291df4b0..ee9d52b4c 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -673,7 +673,7 @@ class PngImageFile(ImageFile.ImageFile): self._text = None self.tile = self.png.im_tile 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) if self.png.im_palette: @@ -685,15 +685,16 @@ class PngImageFile(ImageFile.ImageFile): else: 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.png.save_rewind() self.__rewind_idat = self.__prepare_idat self.__rewind = self.__fp.tell() if self.default_image: # IDAT chunk contains default image and not first animation frame - self._n_frames += 1 + self.n_frames += 1 self._seek(0) + self.is_animated = self.n_frames > 1 @property def text(self): @@ -710,16 +711,6 @@ class PngImageFile(ImageFile.ImageFile): self.seek(frame) 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): """Verify PNG file""" diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c index 20fcbe493..96884ff78 100644 --- a/src/libImaging/Draw.c +++ b/src/libImaging/Draw.c @@ -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. // 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. // // Still using integer grid with step 2 at this point (like in quarter_*)