Commit Graph

111 Commits

Author SHA1 Message Date
Andrew Murray
de3c6fa295 Support converting more modes to LAB by converting to RGBA first 2024-09-07 12:14:30 +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
Hugo van Kemenade
4d6dff34db
Merge pull request #8031 from radarhere/imagingcms_modes 2024-06-28 04:05:40 -06:00
Andrew Murray
cc83cc8ec8 Updated type hints 2024-06-22 10:09:11 +10:00
Andrew Murray
eea3ac765c Deprecate non-image and unsupported modes 2024-06-12 22:44:03 +10:00
Andrew Murray
66ab7e0de2 Added type hints 2024-06-01 21:31:53 +10:00
Andrew Murray
afc7d8d0b0 Added type hints 2024-05-30 17:17:22 +10:00
Andrew Murray
a6d1daeb4b Added type hints 2024-05-29 22:51:02 +10:00
Andrew Murray
e4a10051b6 Corrected test 2024-04-01 23:25:27 +11:00
Andrew Murray
2a93aba5cf Use strncpy to avoid buffer overflow 2024-04-01 09:24:43 +03:00
Nulano
0015e9ce68 expose ImageCms.core.CmsTransform 2024-03-28 17:26:03 +01:00
Nulano
047a0d2a64 do not allow ImageCms.core.CmsProfile to be instantiated directly 2024-03-28 17:24:50 +01:00
Nulano
a1a687c261 add type hints to ImageCms.get_display_profile 2024-03-28 17:23:54 +01:00
Nulano
24ed5db2d1 check type given to ImageCms.core.profile_tobytes instead of crashing 2024-03-28 17:23:54 +01:00
Andrew Murray
7200f47d31 Renamed argument 2024-02-21 08:11:01 +11:00
Andrew Murray
a655d7606e Simplified type hints 2024-02-20 21:27:30 +11:00
Andrew Murray
e39765d755 Added type hints 2024-02-20 15:41:20 +11:00
pre-commit-ci[bot]
27b0cf67e7 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-02-05 17:18:52 +00:00
Hugo van Kemenade
4a4b90c365
Autotype tests (#7756)
* autotyping: --none-return
* autotyping: --scalar-return
* autotyping: --int-param
* autotyping: --float-param
* autotyping: --str-param
* autotyping: --annotate-named-param tmp_path:pathlib.Path
2024-01-31 20:12:58 +11:00
Hugo van Kemenade
53c3cd9f8e isort Tests 2024-01-20 13:23:03 +02:00
Ondrej Baranovič
5347b471c6
Update Tests/test_imagecms.py
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2024-01-11 02:08:46 +01:00
Nulano
08f11c57a1 deprecate ImageCms members: DESCRIPTION, VERSION, FLAGS, versions() 2024-01-08 00:32:47 +01:00
Nulano
90991428fa add LCMS2 flags to ImageCms 2024-01-01 21:40:38 +01:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Hugo van Kemenade
c8ec15980b Remove constants deprecated in 9.1.0 2023-04-06 16:11:36 +03:00
Andrew Murray
ea83ebbcf9 Moved conversion test to test_imagecms, to skip if lcms2 is absent 2023-01-06 20:09:47 +11:00
Hugo van Kemenade
1229110fb2
Update comment
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2022-06-19 15:22:02 +03:00
Hugo van Kemenade
607f508080
Update comment
We get "an integer is required (got type NoneType)" with Python 3.7-3.9 on Windows.

We get "'NoneType' object cannot be interpreted as an integer" with Python 3.10 on Windows and all versions on macOS and Ubuntu.
2022-06-19 12:29:39 +03:00
Hugo van Kemenade
6ae6a241f2 More generic match text 2022-06-15 21:57:20 +03:00
Hugo van Kemenade
983a6139d5 Check other exception messages 2022-06-15 21:42:04 +03:00
Hugo van Kemenade
6c889d1088 Test ImageCms.profileToProfile with invalid flags 2022-06-15 21:34:16 +03:00
Andrew Murray
72b7ab54bd pre-commit autoupdate --freeze 2022-03-04 16:42:24 +11:00
Andrew Murray
ed8073e846 Deprecated constants in favour of enums 2022-01-15 10:07:07 +11:00
Andrew Murray
f8e4e9c2dd Added enums 2022-01-15 09:02:31 +11:00
Andrew Murray
3495b319bd Replaced various instances of assert_image_similar with assert_image_similar_tofile 2021-02-21 22:22:29 +11:00
nulano
40c9a5a2a0 compatibility for LCMS<2.7, vix LCMS version string 2020-10-12 02:58:24 +01:00
Andrew Murray
c196af6ddb Fixed loading profile with non-ASCII path on Windows 2020-09-13 13:53:58 +10:00
Andrew Murray
298b7d0333 Update pre-commit 2020-08-31 18:50:15 +10:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Hugo van Kemenade
559510b378 Remove attributes deprecated since 3.2.0 2020-07-09 23:53:22 +10:00
nulano
a324f4a466 add version to features info block 2020-06-21 18:58:39 +10:00
Hugo
c8e3757e72 Run yesqa to remove redundant noqa 2020-06-06 14:54:58 +03:00
Andrew Murray
e228cfcec7 Lint fixes 2020-06-06 12:08:37 +10:00
Hugo
affade7595 Replace unittest with pytest 2020-02-13 12:15:05 +02: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
Jon Dufresne
63729766c4 Remove unnecessary coerce to float
In Python 3, the division operator is floating point division. No longer
need to coerce integers to floating point numbers before division.
2020-01-26 06:33:18 -08: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
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