Commit Graph

236 Commits

Author SHA1 Message Date
Andrew Murray
67f5e5d272 Test an empty string comment in arguments removes existing comment 2022-05-22 15:01:28 +10:00
Andrew Murray
db76eaa12c
Merge branch 'main' into comment_correct_placement 2022-05-22 14:56:57 +10:00
Andrew Murray
e9cb2156ec
Merge pull request #6294 from raygard/comments_separate_multiple
Separate multiple GIF comment blocks in a frame with newlines
2022-05-22 14:53:03 +10:00
Andrew Murray
62d5817e29 Changed delimiter to \n 2022-05-22 14:11:11 +10:00
Andrew Murray
46a80d144a Update transparency when remapping the palette 2022-05-21 16:37:47 +10:00
Andrew Murray
2072a52bb5
Merge pull request #6292 from raygard/comment_use_gif89a
Always use GIF89a for comments
2022-05-21 10:24:14 +10:00
Hugo van Kemenade
2c58c3ee11
Merge pull request #6213 from radarhere/fp 2022-05-19 18:52:55 +03:00
Andrew Murray
138bd280e4 Added check to test_comment as well 2022-05-19 20:59:32 +10:00
Ray Gardner
6257e788ad
Update test_file_gif.py
Changed to use a test image already in Images folder
2022-05-14 11:57:41 -06:00
pre-commit-ci[bot]
416de882e4 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-05-14 15:36:54 +00:00
Ray Gardner
22d9095e5c Correct placement of GIF comment
Place GIF comment after Global Color table. Should go after "NETSCAPE" looping extension after pull #6211.
2022-05-13 17:09:37 -06:00
Ray Gardner
44c6467400 Multiple GIF comments in a frame are separated
If more than one comment is in a GIF frame, separate them with \r\n in the info dict.
2022-05-13 16:36:20 -06:00
Ray Gardner
b3d29e946a Always use GIF89a for long comments
Fix bug that allows GIFs with long comments to be written as GIF87a.
2022-05-13 11:33:33 -06:00
Andrew Murray
7e084c7ede Use durations from each frame by default when saving 2022-05-03 20:07:47 +10:00
Andrew Murray
e62449f94c Added DeferredError to _fp 2022-04-17 12:14:53 +10:00
Andrew Murray
c8118438ae Do not update frame position until local image is found 2022-04-16 17:07:39 +10:00
Hugo van Kemenade
a715bf2d6f [Test] function name should be snake_case 2022-04-11 15:29:01 +03:00
Andrew Murray
6b2da2f123 Consider transparency from each frame when saving 2022-04-02 21:04:22 +11:00
Hugo van Kemenade
e60ca89721
Merge pull request #6150 from radarhere/gif 2022-03-30 23:23:59 +03:00
Andrew Murray
e22a4395d3 Renamed setting 2022-03-29 21:26:29 +11:00
Hugo van Kemenade
aeba11db1b
Merge pull request #6148 from radarhere/gif_size 2022-03-26 19:48:08 +02:00
Andrew Murray
c5efe60c37 Reverted converting L with transparency to LA after first frame 2022-03-22 22:07:37 +11:00
Andrew Murray
ce8c682748 Added setting to convert to RGB only at a different palette 2022-03-22 20:28:49 +11:00
Andrew Murray
66bb2bd5e8 Added setting to convert first GIF frame to RGB 2022-03-22 20:20:38 +11:00
Andrew Murray
7928e944cb Keep subsequent L frames without transparency as L 2022-03-22 20:20:38 +11:00
Andrew Murray
d806227199 Do not expand GIF during n_frames 2022-03-21 23:19:26 +11:00
Andrew Murray
4e16a9a942 Retain RGBA transparency when saving multiple frames 2022-03-12 15:14:36 +11:00
Andrew Murray
5c6212052c Convert subsequent frames of L mode GIF to LA if transparency is present 2022-03-01 20:11:35 +11:00
Andrew Murray
9006836c28 Test that n_frames and is_animated do not change the image 2022-02-22 08:55:02 +11:00
Andrew Murray
dae1f691c2 Updated checks that no warnings were raised 2022-02-21 13:49:01 +11:00
Andrew Murray
f8e4e9c2dd Added enums 2022-01-15 09:02:31 +11:00
Andrew Murray
0e10a5cc7b When saving RGBA, make use of first transparent palette entry 2021-12-07 06:37:01 +11:00
Andrew Murray
1fb1bec0e8 Added test 2021-11-29 17:49:19 +11:00
Andrew Murray
b383a175be Convert subsequent GIF frames to RGB or RGBA 2021-11-29 17:49:06 +11:00
Hugo van Kemenade
31a96b9c9b Upgrade Python syntax with pyupgrade --py36-plus and format with Black 2021-10-19 15:34:52 +03:00
Andrew Murray
174b4893f3 Prefer global transparency for disposal method 2 2021-10-12 09:45:52 +11:00
Hugo van Kemenade
4c7777c425
Merge pull request #5599 from radarhere/palette
Updates for ImagePalette channel order
2021-08-24 14:52:46 +03:00
Andrew Murray
cf275737ee Do not rearrange palette channels 2021-07-29 16:20:20 +10:00
Andrew Murray
43ea81c6db For save_all with palette, do not include palette with each frame 2021-07-11 22:52:32 +10:00
Hugo van Kemenade
50302231ed
Merge pull request #5552 from radarhere/palette 2021-06-28 19:01:54 +03:00
Andrew Murray
d24299a16c Corrected comments 2021-06-28 20:21:46 +10:00
Andrew Murray
450382f574 Do not use raw ImagePalette 2021-06-27 15:09:39 +10:00
Andrew Murray
f6d504c8f6 Use context manager 2021-06-26 00:48:16 +10:00
Glenn Maynard
432677740d Add a test for an image that works with other GIF decoders.
This test is fixed by the next commits.
2021-06-26 00:48:10 +10:00
Andrew Murray
5b4cb5052a Draw first frame on top of transparency 2021-06-25 21:54:21 +10:00
Andrew Murray
a47072bcbe Treat previous contents of first frame as transparent 2021-04-15 19:01:12 +10:00
Hugo van Kemenade
2f5687f886
Merge pull request #5390 from radarhere/gif_missing_background
Use zero if GIF background color index is missing
2021-04-15 11:57:31 +03:00
Andrew Murray
3cb2413066 Use zero if background color index is missing 2021-04-08 08:04:20 +10:00
Andrew Murray
d661e438f6 Fixed ensuring that previous frame was loaded 2021-04-06 19:31:51 +10:00
Andrew Murray
b216b367ac Only set info transparency on first frame 2021-03-17 00:24:57 +11:00
Andrew Murray
a5c251029c Replaced various instances of assert_image_equal with assert_image_equal_tofile 2021-02-21 22:15:56 +11:00
Andrew Murray
4a0569e97f Changed zero length assertions to falsy 2021-02-11 13:48:31 +11:00
Andrew Murray
01be700081 Fixed asserting that no warnings were raised 2021-02-10 23:37:55 +11:00
Hugo van Kemenade
07bbc46589
Merge pull request #5149 from wiredfool/gif_write_oob_read 2021-01-02 10:14:17 +02:00
Eric Soroos
d96945b7c8 Fix Out of bounds read when saving GIF of xsize=1 2020-12-27 16:01:26 +01:00
Andrew Murray
9940c84b08 Use previous disposal method in load_end 2020-12-23 13:22:53 +11:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Hugo
44e661f25a Convert to use pytest 2020-02-22 23:03:01 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Jon Dufresne
4f185329f4 Streamline test skipping based on supported features
This adds a new test decorator: skip_unless_feature(). The argument is
the same as passed to features.check(). If the feature is not supported,
the test will be skipped.

This removes several kinds of boilerplate copied and pasted around tests
so test feature checking is handled and displayed more consistently.

Refs #4193
2020-02-18 13:07:01 -08:00
Jon Dufresne
967f46d1d8 Remove unnecessary skip test logic
The gif_encoder and gif_decoder are always compiled and included in
src/_imaging.c.
2020-02-18 13:02:30 -08:00
Hugo
38bf862185 Replace PillowTestCase.assert_warning with pytest.warns 2020-02-03 11:11:32 +02:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Andrew Murray
e8bb2dd93e Allow string comment when saving GIF 2020-01-01 13:29:39 +11:00
Alexander
ac92836e81 Change default resize resampling filter 2019-12-07 18:08:19 +03:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Jon Dufresne
33dabf986f Import unittest from stdlib rather than helper.py
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
2019-11-20 18:42:52 -08:00
Hugo
cc63f66575 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
Jon Dufresne
4cd4adddc3 Improve handling of file resources
Follow Python's file object semantics. User code is responsible for
closing resources (usually through a context manager) in a deterministic
way.

To achieve this, remove __del__ functions. These functions used to
closed open file handlers in an attempt to silence Python
ResourceWarnings. However, using __del__ has the following drawbacks:

- __del__ isn't called until the object's reference count reaches 0.
  Therefore, resource handlers remain open or in use longer than
  necessary.

- The __del__ method isn't guaranteed to execute on system exit. See the
  Python documentation:

  https://docs.python.org/3/reference/datamodel.html#object.__del__

  > It is not guaranteed that __del__() methods are called for objects
  > that still exist when the interpreter exits.

- Exceptions that occur inside __del__ are ignored instead of raised.
  This has the potential of hiding bugs. This is also in the Python
  documentation:

  > Warning: Due to the precarious circumstances under which __del__()
  > methods are invoked, exceptions that occur during their execution
  > are ignored, and a warning is printed to sys.stderr instead.

Instead, always close resource handlers when they are no longer in use.
This will close the file handler at a specified point in the user's code
and not wait until the interpreter chooses to. It is always guaranteed
to run. And, if an exception occurs while closing the file handler, the
bug will not be ignored.

Now, when code receives a ResourceWarning, it will highlight an area
that is mishandling resources. It should not simply be silenced, but
fixed by closing resources with a context manager.

All warnings that were emitted during tests have been cleaned up. To
enable warnings, I passed the `-Wa` CLI option to Python. This exposed
some mishandling of resources in ImageFile.__init__() and
SpiderImagePlugin.loadImageSeries(), they too were fixed.
2019-10-12 08:27:17 -07:00
Hugo
4382413bb4 Remove redundant bytearray 2019-10-07 16:23:43 +03:00
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Andrew Murray
2dbfabe6d5 Simplifications 2019-08-24 08:10:45 +10:00
djy0
0872cb4377 fix comment 2019-08-12 18:54:29 +10:00
djy0
63c15dc3ba format 2019-08-12 18:54:29 +10:00
djy0
3c971bec41 format 2019-08-12 18:54:29 +10:00
djy0
8696f06fbe Update test_file_gif.py 2019-08-12 18:54:29 +10:00
Jon Dufresne
d50445ff30 Introduce isort to automate import ordering and formatting
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.

Uses the configuration recommended by the Black to avoid conflicts of
style.

Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00
Andrew Murray
90d3d37164 Do not presume that the background color index is 0 2019-06-29 23:06:45 +10:00
Andrew Murray
97c15a245c Corrected color table size calculation 2019-06-29 23:02:26 +10:00
Andrew Murray
c3e982e0c6
Merge branch 'master' into master 2019-06-29 22:59:17 +10:00
Hugo
d08475442b Format with Black 2019-06-13 18:53:42 +03:00
Andrew Murray
27134340f5 Expand GIF to include frames with extents outside the image size 2019-05-02 19:46:17 +10:00
Riley Lahd
5fb36d2de4 Merge branch 'master' of https://github.com/python-pillow/Pillow 2019-04-09 08:24:52 -06:00
Riley Lahd
ad70fc73cb Linting changes 2019-03-22 08:26:16 -06:00
Riley Lahd
4b2746fc39 Remove disposal 2 duplicate frame exemption and add true delta test 2019-03-22 08:19:01 -06:00
Andrew Murray
7dfbdc01f4 Fixed bug when rewinding to a non-zero frame 2019-03-16 20:02:24 +11:00
Andrew Murray
0b630e06dc Test that background colours read are equal to saved colours 2019-03-15 10:29:33 +11:00
Riley Lahd
85a07bb385 Linting changes 2019-03-14 14:51:13 -06:00
Riley Lahd
96c5a4c543 Add test for disposal mode 2 gifs 2019-03-14 14:40:31 -06:00
Jon Dufresne
4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
With the introduction and use of pytest, it is simple and easy to
execute specific tests in isolation through documented command line
arguments. Either by specifying the module path or through the `-k
EXPRESSION` argument. There is no longer any need to provide the
boilerplate:

    if __name__ == '__main__':
        unittest.main()

To every test file. It is simply noise.

The pattern remains in test files that aren't named with `test_*` as
those files are not discovered and executed by pytest by default.
2019-02-03 10:10:16 -08:00
Jon Dufresne
7da17ad41e Improve pytest configuration to allow specific tests as CLI args
The previous test configuration made it difficult to run a single test
with the pytest CLI. There were two major issues:

- The Tests directory was not a package. It now includes a __init__.py
  file and imports from other tests modules are done with relative
  imports.

- setup.cfg always specified the Tests directory. So even if a specific
  test were specified as a CLI arg, this configuration would also always
  include all tests. This configuration has been removed to allow
  specifying a single test on the command line.

Contributors can now run specific tests with a single command such as:

  $ tox -e py37 -- Tests/test_file_pdf.py::TestFilePdf.test_rgb

This makes it easy and faster to iterate on a single test failure and is
very familiar to those that have previously used tox and pytest.

When running tox or pytest with no arguments, they still discover and
runs all tests in the Tests directory.
2019-01-13 09:00:12 -08:00
Hugo
bbb3be9a9d
Merge pull request #3187 from radarhere/encoderinfo
Wait until mode is normalized to copy im.info into encoderinfo
2018-12-26 12:56:50 +02:00
Hugo
961fecb35c
Merge pull request #3261 from radarhere/fp
Resolve __fp when closing and deleting
2018-12-13 21:09:23 +02:00
Andrew Murray
b2b737b68b Allow arbitrary number of comment extension subblocks 2018-11-27 21:11:22 +11:00
Andrew Murray
f1b2802eb1 Resolved error for comment extension with zero subblocks 2018-11-27 21:09:28 +11:00
Andrew Murray
47775f3d50 Resolve __fp when closing and deleting 2018-11-17 21:56:06 +11:00
Andrew Murray
a7eb2ea9cc Change tuple background to global color table index when saving 2018-10-02 20:52:07 +10:00
Andrew Murray
fbc121d678 Changed GIF seek to remove previous info items 2018-09-01 09:28:22 +10:00
Andrew Murray
de2fbc9dff Wait until mode is normalized to copy im.info into encoderinfo 2018-08-25 00:55:51 +10:00
Andrew Murray
c2189235af Line too long 2018-07-02 19:26:02 +10:00