Commit Graph

200 Commits

Author SHA1 Message Date
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
7319d86328 Catch struct.error from truncated EXIF when reading DPI 2023-10-12 10:13:46 +11:00
Andrew Murray
a3fd009875 Match warning message 2023-10-06 17:31:06 +11:00
Andrew Murray
f24222a954 Merge branch 'main' into jpeg_xmp 2023-10-06 17:23:53 +11:00
Andrew Murray
0a28840bc4 Expand buffer size when optimizing or progressive 2023-08-19 14:34:08 +10:00
Andrew Murray
3f78ba80f9 Do not require curly bracket in tag name 2023-07-10 22:05:28 +10:00
Andrew Murray
2488167f33 Allow for zero-byte padding at end of XMP data 2023-07-10 22:00:30 +10:00
Matthew Treinish
6215cd3e0f
Update tests to handle no longer raising 2023-07-06 09:28:35 -04:00
Andrew Murray
93e507294b Only assert image is similar 2023-05-05 08:19:43 +10:00
Ishant Mrinal Haloi
5377b0735f add _repr_jpg_ for ipython display
Signed-off-by: Ishant Mrinal Haloi <mrinal.haloi11@gmail.com>
2023-05-04 21:43:57 +05:30
Hugo van Kemenade
52f4fc59a2 Remove JpegImagePlugin.convert_dict_qtables, deprecated in 8.3.0 2023-04-06 16:11:36 +03:00
Hugo van Kemenade
d2e77de070
Merge pull request #6853 from radarhere/child_images
Relaxed child images check to allow for libjpeg
2023-02-12 07:26:18 +02:00
Andrew Murray
bb524018d3 Raise an error when EXIF data is too long 2023-02-11 16:20:27 +11: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
97385d7cc7 Relaxed child images check to allow for libjpeg 2023-01-02 19:54:12 +11:00
Andrew Murray
5257d561c0
Merge pull request #6748 from radarhere/exif_ifd
Added IFD enum to ExifTags
2022-12-14 07:33:14 +11:00
Andrew Murray
c2a42655e1 Allow get_child_images to access JPEG thumbnails 2022-12-06 19:30:53 +11:00
Sam Mason
1ed1a3a971
make sure passing a blank comment removes existing comment 2022-12-03 15:07:37 +00:00
Andrew Murray
525c01143a Test that comment is reread 2022-12-03 09:59:22 +11:00
pre-commit-ci[bot]
e9f4858491 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-12-02 18:07:10 +00:00
Sam Mason
d822d85af6
support round-tripping JPEG comments 2022-12-02 17:57:19 +00:00
Mark Mayo
69baeccf2e some pylint warnings
Fixed some pylint issues
2022-10-13 15:20:11 +13:00
Andrew Murray
c259ac492f Parametrized tests 2022-10-03 16:57:42 +11:00
Hugo van Kemenade
d42efd7ec0
Update URL (#16) 2022-04-28 08:26:57 +10:00
Andrew Murray
ae8de77721 Raise ValueError when trying to save empty image 2022-03-28 21:18:53 +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
1059eb5376 If appended EOI did not work, do not keep trying 2022-01-01 21:04:32 +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
98aa0f10ad pre-commit autoupdate --freeze 2021-08-12 21:50:09 +10:00
Alexander Karpinsky
3abe5e884b Add TypeError handling to pass corrupted dpi value in exif 2021-07-26 16:13:01 +03:00
Andrew Murray
d11c794997 Merge branch 'master' into 4962-jpeg-zigzag 2021-06-30 20:54:55 +10:00
Andrew Murray
0aa8bd00e7 Added warning if defusedxml is not found 2021-06-30 11:29:13 +10:00
Andrew Murray
d9d811ff21 Replaced xml.etree.ElementTree with defusedxml.ElementTree 2021-06-30 11:28:44 +10:00
Andrew Murray
a1d8d638bf
Checked complete length of value 2021-06-29 19:41:00 +10:00
Andrew Murray
cd31dae0d1 Added getxmp() for PNG 2021-06-12 13:57:14 +10:00
Andrew Murray
c1fbe2d975 Corrected getxmp() descending into XML 2021-06-12 11:58:11 +10:00
Andrew Murray
18e204df05 Removed DPI rounding from JPEG loading 2021-05-07 21:23:29 +10:00
Andrew Murray
6967f3519f Test when "adobe_transform" is unable to be read 2021-04-20 20:53:50 +10:00
Andrew Murray
4351c37fc4 Corrected adobe_transform value 2021-04-15 21:49:51 +10:00
Eric Soroos
1c872a9eda lint stuff 2021-04-10 16:58:01 +02:00
Eric Soroos
a3a69c8385 conditional mark for valgrind ignore 2021-04-09 23:53:24 +02:00
Andrew Murray
2c8684c525 Moved getxmp() into JpegImageFile 2021-04-01 22:28:37 +11:00
Andrew Murray
c52b45df62 Removed automatic retrieval of GPS IFD 2021-03-15 12:33:06 +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
Andrew Murray
a5c251029c Replaced various instances of assert_image_equal with assert_image_equal_tofile 2021-02-21 22:15:56 +11:00
Hugo van Kemenade
1857bf5570
Merge pull request #5259 from radarhere/warns 2021-02-17 21:31:15 +02:00
Andrew Murray
83542c42bf Added context managers 2021-02-11 21:43:54 +11:00
Andrew Murray
4a0569e97f Changed zero length assertions to falsy 2021-02-11 13:48:31 +11:00
Eric Soroos
1d7c8e03d0 known failing tests from valgrind -- uninitialized values 2021-01-07 14:52:02 +01:00