mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-30 09:59:50 +03:00
Merge branch 'main' into qoi_write
This commit is contained in:
commit
c5446672af
|
@ -7,9 +7,8 @@ import pytest
|
|||
from PIL import BlpImagePlugin, Image
|
||||
|
||||
from .helper import (
|
||||
assert_image_equal,
|
||||
assert_image_equal_tofile,
|
||||
assert_image_similar,
|
||||
assert_image_similar_tofile,
|
||||
hopper,
|
||||
)
|
||||
|
||||
|
@ -52,18 +51,16 @@ def test_save(tmp_path: Path) -> None:
|
|||
im = hopper("P")
|
||||
im.save(f, blp_version=version)
|
||||
|
||||
with Image.open(f) as reloaded:
|
||||
assert_image_equal(im.convert("RGB"), reloaded)
|
||||
assert_image_equal_tofile(im.convert("RGB"), f)
|
||||
|
||||
with Image.open("Tests/images/transparent.png") as im:
|
||||
f = tmp_path / "temp.blp"
|
||||
im.convert("P").save(f, blp_version=version)
|
||||
|
||||
with Image.open(f) as reloaded:
|
||||
assert_image_similar(im, reloaded, 8)
|
||||
assert_image_similar_tofile(im, f, 8)
|
||||
|
||||
im = hopper()
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(ValueError, match="Unsupported BLP image mode"):
|
||||
im.save(f)
|
||||
|
||||
|
||||
|
|
|
@ -294,9 +294,10 @@ def test_header_token_too_long(tmp_path: Path, data: bytes) -> None:
|
|||
with open(path, "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
with pytest.raises(ValueError, match="Token too long in file header: "):
|
||||
with pytest.raises(ValueError) as e:
|
||||
with Image.open(path):
|
||||
pass
|
||||
assert "Token too long in file header: " in repr(e)
|
||||
|
||||
|
||||
def test_truncated_file(tmp_path: Path) -> None:
|
||||
|
|
|
@ -54,6 +54,19 @@ Support has been added for saving QOI images. ``colorspace`` can be used to spec
|
|||
colorspace as sRGB with linear alpha, e.g. ``im.save("out.qoi", colorspace="sRGB")``.
|
||||
By default, all channels will be linear.
|
||||
|
||||
Support using more screenshot utilities with ImageGrab on Linux
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:py:meth:`~PIL.ImageGrab.grab` is now able to use GNOME Screenshot, grim or Spectacle
|
||||
on Linux in order to take a snapshot of the screen.
|
||||
|
||||
Do not build against libavif < 1
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Pillow only supports libavif 1.0.0 or later. In order to prevent errors when building
|
||||
from source, if a user happens to have an earlier libavif on their system, Pillow will
|
||||
now ignore it.
|
||||
|
||||
Python 3.14 beta
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -338,12 +338,6 @@ static const char *no_palette = "image has no palette";
|
|||
static const char *readonly = "image is readonly";
|
||||
/* static const char* no_content = "image has no content"; */
|
||||
|
||||
void *
|
||||
ImagingError_OSError(void) {
|
||||
PyErr_SetString(PyExc_OSError, "error when accessing file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
ImagingError_MemoryError(void) {
|
||||
return PyErr_NoMemory();
|
||||
|
@ -369,11 +363,6 @@ ImagingError_ValueError(const char *message) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ImagingError_Clear(void) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* HELPERS */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -54,7 +54,7 @@ ImagingSavePPM(Imaging im, const char *outfile) {
|
|||
|
||||
fp = fopen(outfile, "wb");
|
||||
if (!fp) {
|
||||
(void)ImagingError_OSError();
|
||||
PyErr_SetString(PyExc_OSError, "error when accessing file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,8 +270,6 @@ ImagingSectionLeave(ImagingSectionCookie *cookie);
|
|||
/* Exceptions */
|
||||
/* ---------- */
|
||||
|
||||
extern void *
|
||||
ImagingError_OSError(void);
|
||||
extern void *
|
||||
ImagingError_MemoryError(void);
|
||||
extern void *
|
||||
|
@ -280,8 +278,6 @@ extern void *
|
|||
ImagingError_Mismatch(void); /* maps to ValueError by default */
|
||||
extern void *
|
||||
ImagingError_ValueError(const char *message);
|
||||
extern void
|
||||
ImagingError_Clear(void);
|
||||
|
||||
/* Transform callbacks */
|
||||
/* ------------------- */
|
||||
|
|
|
@ -645,7 +645,7 @@ ImagingNewInternal(const char *mode, int xsize, int ysize, int dirty) {
|
|||
return im;
|
||||
}
|
||||
|
||||
ImagingError_Clear();
|
||||
PyErr_Clear();
|
||||
|
||||
// Try to allocate the image once more with smallest possible block size
|
||||
MUTEX_LOCK(&ImagingDefaultArena.mutex);
|
||||
|
|
Loading…
Reference in New Issue
Block a user