Commit Graph

3459 Commits

Author SHA1 Message Date
Andrew Murray
ab96324c12 Removed support for RGB bitcount 8 2023-12-02 21:36:17 +11:00
Andrew Murray
56b4822294 args may be a string or None 2023-12-02 21:36:17 +11:00
Andrew Murray
662cb229c2 Updated variable name to match tile 2023-12-02 21:36:17 +11:00
Andrew Murray
49578f0059
Merge branch 'main' into improved_dds 2023-12-02 21:35:20 +11:00
Andrew Murray
a6a612c6c5
Merge branch 'main' into fix-alpha-for-overlapping-glyphs 2023-12-02 21:33:29 +11:00
Andrew Murray
96fe0a103b Merge branch 'main' into ImageStat_getextrema_opt 2023-12-02 21:27:36 +11:00
Zach Nagengast
bd2977c518
Update src/PIL/ImageDraw.py
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-12-01 22:56:59 -08:00
Andrew Murray
0e523d9868 Fixed closing file pointer with olefile 0.47 2023-12-02 10:57:16 +11:00
Andreas Florath
7762dd382a Fixed spacing in _getextrema method
Signed-off-by: Andreas Florath <andreas@florath.net>
2023-12-01 18:53:44 +01:00
Andreas Florath
1b8f9d386b Optimize ImageStat.Stat._getextrema function
The optimzed function improves the performance.  The original function
always runs through the complete historgram of length 256 even if it
is possible to exit the loop early (break).

Running some tests I found performance improvements of factor >10
depending on the image.

Signed-off-by: Andreas Florath <andreas@florath.net>
2023-12-01 18:53:44 +01:00
Andreas Florath
e01354a2c8 Added space before colon
Signed-off-by: Andreas Florath <andreas@florath.net>
2023-12-01 18:52:27 +01:00
Andreas Florath
f7d40ce31c Removed functools and operator import which are not needed anymore
Signed-off-by: Andreas Florath <andreas@florath.net>
2023-12-01 18:52:27 +01:00
Andreas Florath
a04c6a27e8 Optimization of ImageStat.Stat._getcount method
The new implementation uses "sum" instead of the construct
"functools.reduce(operator.add, ...)". Test showed that the
new function is about three times faster than the original.
Also it is shorter and easier to read.

Signed-off-by: Andreas Florath <andreas@florath.net>
2023-12-01 18:52:27 +01:00
Hugo van Kemenade
76446ee450
Merge pull request #7524 from cclauss/ruff-rules-C4-PERF102-PIE810-PLR 2023-12-01 17:09:25 +02:00
Andrew Murray
2e8dd3bdca Use int.from_bytes() 2023-12-01 22:56:25 +11:00
Andrew Murray
30eb41475d Use f-string
Co-authored-by: Aarni Koskela <akx@iki.fi>
2023-12-01 22:44:51 +11:00
Nulano
984700b1f7 fix documentation link to PIL.ImageFont.Layout 2023-11-30 23:58:47 +01:00
Andrew Murray
13c1d752c6
Use enum in type hint
Co-authored-by: Ondrej Baranovič <nulano@nulano.eu>
2023-12-01 08:42:25 +11:00
Andrew Murray
f1fef09d4a Support arbitrary masks for uncompressed RGB images 2023-11-30 21:13:59 +11:00
Andrew Murray
f23d029d5f Moved error from truetype() to FreeTypeFont 2023-11-30 07:41:02 +11:00
Andrew Murray
5fb86c55ed Moved code closing fp and _fp into common method 2023-11-29 20:05:17 +11:00
Zach Nagengast
78f78d2aa7
Update src/_imagingft.c
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-11-28 11:53:46 -08:00
Aarni Koskela
39ec56c6ea Improve error message when creating TrueType fonts of invalid size
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-11-28 15:09:53 +02:00
helloworld
b235aa98c6 fix: use parent_name instead of parent_module 2023-11-28 20:21:03 +08:00
Andrew Murray
4bc365547a
Corrected type hint
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-11-28 21:43:58 +11:00
Andrew Murray
9e8edb42b6 Added type hint 2023-11-28 21:18:58 +11:00
Deliang Yang
6825a76692 fix: Importing plugins from a user-specified installation directory
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

fix: Wrong path replacement

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

fix: typo
2023-11-28 08:25:16 +08:00
Zach Nagengast
9c60e856ad
Apply suggestions from code review
Co-authored-by: Ondrej Baranovič <nulano@nulano.eu>
2023-11-27 09:20:40 -08:00
Nulano
0cef9f251c fix drawing text alpha on RGBA image on big-endian platforms 2023-11-27 17:12:12 +01:00
Andrew Murray
ae7958fa8d Handle pathlib.Path in FreeTypeFont 2023-11-27 23:03:10 +11:00
Andrew Murray
55c5587437 Fill identical pixels with transparency in subsequent frames 2023-11-25 19:16:32 +11:00
Andrew Murray
f59b51fdc7 Simplified code 2023-11-25 17:36:19 +11:00
Andrew Murray
5431b15bd2 Do not assign new fp attribute to image when exiting context manager 2023-11-24 15:19:19 +11:00
Andrew Murray
a07bac3a56 Attempt memory mapping when tile args is a string 2023-11-21 21:45:14 +11:00
Andrew Murray
524b823c1b Removed unnecessary string length check 2023-11-17 17:41:47 +11:00
Andrew Murray
67e1253202 Do not assign new fp attribute to image when closing 2023-11-17 08:32:25 +11:00
Raphael Vieira Rossi
b25ece364b
fix: check object Image has attribute 'fp' when closes 2023-11-16 16:46:11 -03:00
Andrew Murray
98b73009cc Correct PDF palette size when saving 2023-11-16 23:01:26 +11:00
Andrew Murray
4b308dc2bf
Merge pull request #7488 from bgilbert/jpeg-restart
Allow configuring JPEG restart marker interval on save
2023-11-14 23:42:50 +11:00
Hugo van Kemenade
902055fbfe
Merge pull request #7526 from akx/mount-ruffmore 2023-11-13 16:15:06 +02:00
Aarni Koskela
f47633a24a
Apply suggestions from code review
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-11-13 09:28:01 +02:00
Andrew Murray
086ca274fa Decrement reference count for PyObject 2023-11-13 15:11:28 +11:00
Andrew Murray
f016d3079b Determine mask mode in Python instead of C 2023-11-13 14:31:22 +11:00
Aarni Koskela
126bc44e9e Fix up most noqas
Update Tests/bench_cffi_access.py

Co-authored-by: Alexander Karpinsky <homm86@gmail.com>
2023-11-12 13:47:52 +02:00
Hugo van Kemenade
556dd1e15c
Merge pull request #7535 from hugovk/add-3.13 2023-11-12 00:34:12 +02:00
Hugo van Kemenade
9b8c23e2dd
Merge pull request #7527 from akx/remove-commented-out-code 2023-11-11 14:32:15 +02:00
Andrew Murray
bf76320444
Merge pull request #7491 from bgilbert/jpeg-tables-only
Implement `streamtype=1` option for tables-only JPEG encoding
2023-11-11 16:06:34 +11:00
Hugo van Kemenade
9b88cf5ad9 #ifdef _UNISTD_H -> HAVE_UNISTD_H 2023-11-08 18:48:40 +02:00
Hugo van Kemenade
95eef25aca Fix for Python 3.13: explicitly include unistd.h 2023-11-08 17:52:43 +02:00
ZachNagengast
11bea8fea6 Merge branch 'main' of ssh://github.com/python-pillow/Pillow into fix-alpha-for-overlapping-glyphs 2023-11-07 06:34:31 -08:00
Hugo van Kemenade
a7fe25df53
Merge pull request #7522 from radarhere/png_save_all 2023-11-07 11:35:24 +02:00
ZachNagengast
8ecf2e9f30 Merge branch 'fix-alpha-for-overlapping-glyphs' of ssh://github.com/ZachNagengast/Pillow into fix-alpha-for-overlapping-glyphs 2023-11-06 21:11:36 -08:00
ZachNagengast
fdecfca9f4 Update gray glyph blending logic and tests 2023-11-06 21:11:28 -08:00
Zach Nagengast
b15b2d494c
Update src/_imagingft.c
Co-authored-by: Ondrej Baranovič <nulano@nulano.eu>
2023-11-06 20:48:22 -08:00
Aarni Koskela
0c705692ea Remove old commented-out code 2023-11-06 21:21:07 +02:00
pre-commit-ci[bot]
eb8405baa0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-11-06 13:24:42 +00:00
Christian Clauss
fd59f91d17 ruff: Minor optimizations of list comprehensions, x in set, etc. 2023-11-06 19:13:47 +06:00
Aarni Koskela
9e615b6ad3 Add noqas for UP031 2023-11-06 12:43:14 +02:00
Aarni Koskela
307d00b44d Apply ruff autofixes 2023-11-06 12:43:14 +02:00
ZachNagengast
e1aaec3fb1 Merge branch 'main' of ssh://github.com/python-pillow/Pillow into fix-alpha-for-overlapping-glyphs 2023-11-03 15:09:07 -07:00
ZachNagengast
a7f805d889 Merge branch 'fix-alpha-for-overlapping-glyphs' of ssh://github.com/ZachNagengast/Pillow into fix-alpha-for-overlapping-glyphs 2023-11-03 15:08:50 -07:00
ZachNagengast
bb0eff44cd Update blending logic
- Unpremultiply properly
- No longer uses floats
2023-11-03 15:05:55 -07:00
Andrew Murray
c29648ff53 If save_all PNG only has one frame, do not create animated image 2023-11-03 22:08:48 +11:00
Andrew Murray
dc0379fea5 Corrected combining durations from multiple frames into single frame 2023-11-03 21:09:16 +11:00
Andrew Murray
a5a6ca150c
Merge pull request #7493 from radarhere/frombytes
Fixed frombytes() for images with a zero dimension
2023-11-03 18:56:34 +11:00
Andrew Murray
7c2b681183 Handle disposing background from outside palette 2023-11-02 16:05:13 +11:00
Benjamin Gilbert
e572722479 Allow configuring JPEG restart marker interval on save
libjpeg allows specifying the marker interval either in MCU blocks or in
MCU rows.  Support both, via separate parameters, rather than requiring
callers to do the math.

Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
2023-10-31 17:47:25 -05:00
Andrew Murray
8814610635 Only unpack masks when necessary 2023-10-30 22:16:55 +11:00
REDxEYE
cb554c6d0f
Update src/PIL/DdsImagePlugin.py
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-10-30 13:55:02 +03:00
Andrew Murray
e3ff5eb8e4 Test BC1_UNORM and BC1_TYPELESS 2023-10-30 19:53:51 +11:00
Andrew Murray
0051fc9cf8 Removed unnecessary seek 2023-10-28 16:43:43 +11:00
Andrew Murray
3652f431c2 Simplified code 2023-10-28 14:22:39 +11:00
Andrew Murray
76f758e1ef Merge branch 'main' into fix-alpha-for-overlapping-glyphs 2023-10-28 00:41:41 +11:00
pre-commit-ci[bot]
49fd2116c3 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-10-27 05:03:04 +00:00
ZachNagengast
f97570f523 Blend colors with alpha when pasting
- Previously took the highest alpha as threshold
2023-10-26 21:40:41 -07:00
Andrew Murray
e10a58ccce Concatenate multiple EXIF markers 2023-10-26 21:46:38 +11:00
Andrew Murray
85485229e3 Support RGB bitcount 8 2023-10-25 16:24:00 +11:00
Andrew Murray
f58f410b21 ALPHA by itself does not mean bitcount is valid 2023-10-25 15:30:59 +11:00
Benjamin Gilbert
4d7372bfd0 Implement streamtype=1 option for tables-only JPEG encoding
We already support streamtype=2 to skip producing JPEG tables, but
streamtype=1, which skips everything but the tables, was never implemented.
The streamtype=1 stub code dates to Git pre-history, so it's not
immediately clear why.  Implement the missing support.

jpeg_write_tables() can't resume after a full output buffer (it fails with
JERR_CANT_SUSPEND), so it might seem that Pillow needs to pre-compute the
necessary buffer size.  However, in the normal case of producing an
interchange stream, the tables are written via the same libjpeg codepath
during the first jpeg_write_scanlines() call, and table writes aren't
resumable there either.  Thus, any buffer large enough for the normal case
will also be large enough for a tables-only file.

The streamtype option isn't documented and this commit doesn't change that.
It does add a test though.

Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
2023-10-24 20:30:45 -05:00
Andrew Murray
91f115bead Fixed im.frombytes() for images with a zero dimension 2023-10-25 08:52:26 +11:00
Andrew Murray
5071692039 Fixed Image.frombytes() for images with a zero dimension 2023-10-25 08:52:06 +11:00
Yay295
6ddf10c747
use format string instead of concatenation
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-10-23 21:46:54 -05:00
Yay295
ef46608974
add mode to error message 2023-10-23 19:26:08 -05:00
Andrew Murray
12e41e84cd Simplified creating raw tiles 2023-10-21 19:12:52 +11:00
Andrew Murray
8fbb610378 Derive bit count from number of modes 2023-10-21 17:33:04 +11:00
Andrew Murray
4a4a1ee6ad Simplified tile creation 2023-10-21 16:03:21 +11:00
Andrew Murray
a54d28a7bc Merge branch 'main' into improved_dds 2023-10-21 14:27:31 +11:00
Andrew Murray
935958c990 Removed unnecessary casting to enums 2023-10-21 14:27:23 +11:00
Andrew Murray
5056850a2f Seek past the data when skipping a layer 2023-10-20 16:09:13 +11:00
Andrew Murray
19aeed07bf Merge branch 'main' into gray 2023-10-20 07:47:17 +11:00
Andrew Murray
d682c18ded Use "gray" more consistently 2023-10-19 19:12:01 +11:00
Andrew Murray
8b71f3d3c1 Added messages to errors 2023-10-19 18:42:41 +11:00
Andrew Murray
51f7359c94 Loop over enums to create constants 2023-10-17 19:50:17 +11:00
Andrew Murray
5e9a2e3000 Renamed "tile_args" to "args" for consistency with existing ImageFile variable 2023-10-17 19:10:24 +11:00
Hugo van Kemenade
0be67e5544 10.2.0.dev0 version bump 2023-10-15 16:05:50 +03:00
Hugo van Kemenade
da59ad000d 10.1.0 version bump 2023-10-15 11:59:17 +03:00
Andrew Murray
c2d50881ee Added documentation 2023-10-14 11:01:57 +11:00
Andrew Murray
0da7ad7c48 Merge branch 'main' into load_default 2023-10-14 10:33:50 +11:00
Hugo van Kemenade
ebefb5f1e0
Merge pull request #7442 from radarhere/warning 2023-10-14 01:30:59 +02:00
Hugo van Kemenade
8e5570e23b
Merge pull request #7444 from radarhere/bgr 2023-10-14 01:30:31 +02:00
mergify[bot]
a4bc7146e5
Merge pull request #7412 from radarhere/cover
Added ImageOps cover method
2023-10-13 22:16:30 +00:00
Hugo van Kemenade
ff37a5be37
Merge pull request #7458 from radarhere/truncated_exif 2023-10-13 23:49:55 +02:00
Hugo van Kemenade
101154e0d5
Merge pull request #7437 from radarhere/apng 2023-10-13 23:48:22 +02:00
Hugo van Kemenade
810f5f06c4
Merge branch 'main' into cover 2023-10-13 23:42:06 +02:00
Andrew Murray
31df7b1655 Use new() instead of Image()._new() 2023-10-13 15:41:26 +11:00
REDxEYE
69b922d138 Replace self.mode with self._mode 2023-10-12 22:26:00 +03:00
REDxEYE
2a6bcc18fe Add missing annotation import 2023-10-12 22:19:39 +03:00
pre-commit-ci[bot]
bc6c973e2d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-10-12 16:19:24 +00:00
REDxEYE
6dd565b4a3 Merge remote-tracking branch 'pillow/main' into improved_dds
# Conflicts:
#	Tests/test_file_dds.py
#	src/PIL/DdsImagePlugin.py
2023-10-12 19:15:06 +03:00
REDxEYE
a5dde8b1c4 Apply suggestion for PR 2023-10-12 19:09:28 +03:00
Andrew Murray
7319d86328 Catch struct.error from truncated EXIF when reading DPI 2023-10-12 10:13:46 +11:00
Andrew Murray
ceca12e876
Restored comment 2023-10-07 07:00:29 +00:00
Andrew Murray
d9283fd1f8
Use default value
Co-authored-by: Alexander Karpinsky <homm86@gmail.com>
2023-10-07 17:09:17 +11:00
Andrew Murray
57c1cf603e Fixed may be used uninitialized warning 2023-10-07 01:15:04 +11:00
Andrew Murray
4e7f61f459
Merge branch 'main' into bgr 2023-10-06 18:50:25 +11:00
Hugo van Kemenade
5957f109a5
Merge pull request #7310 from radarhere/cmyk2rgb 2023-10-06 01:43:50 -06:00
Andrew Murray
f24222a954 Merge branch 'main' into jpeg_xmp 2023-10-06 17:23:53 +11:00
Hugo van Kemenade
7b17f9bbb4
Merge pull request #7415 from radarhere/tiff 2023-10-06 00:11:18 -06:00
Andrew Murray
b8c30655cc Include CMYK to RGB convert as unpacker 2023-10-06 16:05:03 +11:00
Andrew Murray
787daa9f19 Merge branch 'main' into cmyk2rgb 2023-10-06 15:52:32 +11:00
Andrew Murray
2d9c4e663f
Merge pull request #7302 from radarhere/png_i16
Allow saving I;16B images as PNG
2023-10-06 15:45:58 +11:00
Andrew Murray
7394e5083d
Merge branch 'main' into tiff 2023-10-06 11:40:05 +11:00
Hugo van Kemenade
6f73691564
Merge pull request #7257 from radarhere/i16_point 2023-10-05 12:54:25 -06:00
Hugo van Kemenade
09605ff48e
Merge pull request #7413 from radarhere/bc5s 2023-10-05 09:48:12 -06:00
Hugo van Kemenade
0c55a2d864
Merge pull request #7319 from radarhere/iptc 2023-10-05 09:44:56 -06:00
Hugo van Kemenade
5f04b3d278
Merge pull request #7289 from radarhere/undefined_palette 2023-10-05 09:31:02 -06:00
Hugo van Kemenade
4d66f9396b
Merge pull request #7247 from radarhere/getmask2_max_image_pixels 2023-10-05 09:28:04 -06:00
Hugo van Kemenade
0a432541ae
Merge pull request #7392 from radarhere/eps 2023-10-05 09:27:06 -06:00
Andrew Murray
29d23cfe07 Fixed invalid argument warning 2023-10-04 13:56:58 +11:00
Andrew Murray
c9ba107c2c Palette is unneeded as RGB to P conversion will not occur 2023-10-02 19:08:17 +11:00
Andrew Murray
b98dc8abe1 Consider default image when selecting mode for PNG save_all 2023-10-02 19:07:56 +11:00
Andrew Murray
60d88389ae Removed unused code 2023-10-02 11:11:35 +11:00
Andrew Murray
43e6826199
Merge pull request #7382 from nopperl/parse-eps-trailer
Read bounding box information from the trailer of EPS files if specified
2023-10-02 09:53:35 +11:00
Hugo van Kemenade
c2f7ea59b9
Merge pull request #7426 from radarhere/dds_palette 2023-09-30 14:40:17 -06:00
Andrew Murray
955b2d553c
Merge branch 'main' into cover 2023-09-30 19:04:22 +10:00
Hugo van Kemenade
8cb1e29491
Merge pull request #7420 from radarhere/transparency 2023-09-30 02:53:22 -06:00
Andrew Murray
620098571a
Corrected comment priority 2023-09-30 07:54:39 +00:00
Hugo van Kemenade
99e11f9e08
Merge pull request #7406 from radarhere/webp 2023-09-28 14:25:34 -06:00
Andrew Murray
cd4adb1677 Added reading 8-bit color images 2023-09-27 19:41:45 +10:00
Andrew Murray
e27d7a6f84 Changed has_transparency_data() to property 2023-09-26 20:14:22 +10:00
Andrew Murray
1c30809245 Allow for LA or PA in the future 2023-09-26 20:10:52 +10:00
Andrew Murray
faa66eaa6c
Added type hint
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-26 20:10:12 +10:00
Hugo van Kemenade
f76b63d016 Add end-of-file-fixer to pre-commit 2023-09-25 16:45:38 +03:00
Hugo van Kemenade
507b7d519a Fix LOG011 avoid pre-formatting log messages 2023-09-25 16:45:38 +03:00
Hugo van Kemenade
0d1e83098d Add pyupgrade to pre-commit 2023-09-25 16:45:38 +03:00
Andrew Murray
ad12caecda Convert RGBA palette to RGBA image when saving WebP 2023-09-25 20:28:25 +10:00
Andrew Murray
6bbed1add0 Added has_transparency_data() 2023-09-25 20:10:44 +10:00
Andrew Murray
d919942f8e Last trailer comment has priority 2023-09-22 18:36:52 +10:00
Andrew Murray
9de4b72c97 Trailer is not in header, ImageData or itself 2023-09-22 18:26:50 +10:00
Andrew Murray
094f23dd5c EOF ends not just the trailer, but also the file 2023-09-22 18:26:41 +10:00