Commit Graph

96 Commits

Author SHA1 Message Date
Andrew Murray
8f1157a61d Added type hints to Image.__init__() 2024-08-02 23:30:27 +10:00
Andrew Murray
4aa24f88d9
Added type hints to tests (#8203)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
2024-07-05 11:56:24 -06:00
Andrew Murray
267c0b37b1 Added type hints 2024-07-02 20:10:47 +10:00
Andrew Murray
e79d1746f2 Support conversion from RGB to La 2024-03-26 19:57:17 +11:00
Andrew Murray
ab8f465f1a Use transparency info when converting from RGB to LA 2024-03-26 19:55:22 +11:00
Andrew Murray
8b6a182815 Support conversion from RGB to RGBa 2024-03-21 16:25:40 +11:00
Andrew Murray
ddb7df0ec6 Added type hints 2024-01-25 22:18:46 +11:00
Hugo van Kemenade
53c3cd9f8e isort Tests 2024-01-20 13:23:03 +02:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Andrew Murray
fd310512b9 Set C palette to be empty by default 2023-07-17 23:04:43 +10:00
Hugo van Kemenade
14e0128873
Merge pull request #6866 from radarhere/lcms2 2023-03-12 12:39:07 +02:00
pre-commit-ci[bot]
24183d652e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-02-06 19:27:19 +00:00
Andrew Murray
ea83ebbcf9 Moved conversion test to test_imagecms, to skip if lcms2 is absent 2023-01-06 20:09:47 +11:00
Andrew Murray
5b4703d615 Added conversion from RGBa to RGB 2022-11-01 08:39:02 +11:00
Hugo van Kemenade
bb2016794f
Merge pull request #6647 from radarhere/rgb2lab 2022-10-19 10:32:03 +02:00
Andrew Murray
fcd3eef594 Added conversion between RGB/RGBA/RGBX and LAB 2022-10-07 22:33:45 +11:00
Andrew Murray
b8cd3e72a6 Do not attempt normalization if image is already normal 2022-10-07 09:48:56 +11:00
Hugo van Kemenade
0b5c150805
Merge pull request #6497 from radarhere/convert 2022-08-31 17:09:38 +03:00
Andrew Murray
0ed03d4a58 Parametrize tests 2022-08-23 21:41:32 +10:00
Andrew Murray
8a60db322f Copy palette when converting from P to PA 2022-08-17 17:05:53 +10:00
Andrew Murray
b0bc74a297 Only test alpha channel values 2022-05-28 09:24:42 +10:00
Davide Consalvo
9a14be898c added p2pa test 2022-05-27 12:34:05 +02:00
Hugo van Kemenade
9d87b26a67 Don't redeclare loop variable 2022-04-10 23:39:54 +03:00
Hugo van Kemenade
652542c770
Merge pull request #6112 from radarhere/i_i16_conversion
Clip I;16 to be unsigned, not signed
2022-03-10 19:56:45 +02:00
Andrew Murray
c8b69a78f3 Clip I;16 to be unsigned, not signed 2022-03-05 13:42:39 +11:00
Andrew Murray
e2b007f0c2 Use transparency info key when converting to LA 2022-03-01 20:25:25 +11:00
Hugo van Kemenade
07741c9315
Merge pull request #5954 from radarhere/enum 2022-02-18 15:53:41 +02:00
Andrew Murray
83d4f451fa Ensure image is opaque after converting P to PA with RGB palette 2022-02-14 16:10:59 +11:00
Andrew Murray
f8e4e9c2dd Added enums 2022-01-15 09:02:31 +11:00
Hugo van Kemenade
e7b53259d1
Merge pull request #5824 from radarhere/l_macro
Added rounding when converting P and PA
2021-12-28 10:02:36 +02:00
Andrew Murray
73ccda9cd1 Do not compare properties to themselves 2021-12-26 13:27:41 +11:00
Andrew Murray
bb6212a332 Added rounding when converting P and PA 2021-11-10 08:00:58 +11:00
Hugo van Kemenade
3d35e5458f
Merge pull request #5606 from radarhere/convert_transparency 2021-08-13 13:18:39 +03:00
Andrew Murray
97e0cb85ee Keep transparency when converting from P to LA or PA 2021-07-12 22:55:12 +10:00
Andrew Murray
fdfa9e8521 If default conversion from P is RGB with transparency, convert to RGBA 2021-07-08 17:08:11 +10:00
Andrew Murray
1ee30ded0b Fixed reloading palette 2021-06-28 22:27:05 +10:00
Andrew Murray
804183c248 Only use an RGBA palette for images with an alpha channel 2021-06-27 18:29:02 +10:00
Andrew Murray
7005e66f00 Use first index for repeated color 2021-06-27 16:33:47 +10:00
Andrew Murray
450382f574 Do not use raw ImagePalette 2021-06-27 15:09:39 +10:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Andrew Murray
09b9198176 Converted to pytest 2020-02-25 20:57:27 +11:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11: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
c0048ad7de Use context managers 2019-11-26 07:03:23 +11: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
Andrew Murray
27d6fc7bc5 Improved HSV conversion 2019-08-12 06:50:18 +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
Hugo
77f946d8bc Format with Black 2019-06-13 18:54:24 +03:00
Andrew Murray
231fe4d62a Revert "Merge pull request #3838 from radarhere/i_conversion"
This reverts commit 41f3e7c8bd, reversing
changes made to 2f84482871.
2019-06-11 19:28:31 +10:00