Skip to content

Commit f1ec4ce

Browse files
committed
fix issues in 3.1.0
- fix get_gainmap arguments [jcupitt] - fix __array__ copy argument [jcupitt] - add a test [jcupitt]
1 parent 69b4988 commit f1ec4ce

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Version 3.1.1 (released 9 December 2025)
2+
3+
- fix get_gainmap arguments [jcupitt]
4+
- fix __array__ copy argument test [jcupitt]
5+
- add a test [jcupitt]
6+
17
## Version 3.1.0 (released 8 December 2025)
28

39
- fix glib DLL name with Conan [boussaffawalid]

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# The short X.Y version.
6767
version = u'3.1'
6868
# The full version, including alpha/beta/rc tags.
69-
release = u'3.1.0'
69+
release = u'3.1.1'
7070

7171
# The language for content autogenerated by Sphinx. Refer to documentation
7272
# for a list of supported languages.

pyvips/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# this is used in pyproject.toml and imported into __init__.py
2-
__version__ = '3.1.0'
2+
__version__ = '3.1.1'
33

44
__all__ = ['__version__']

pyvips/vimage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ def set_kill(self, kill):
982982

983983
# get/set metadata
984984

985-
def get_gainmap(self, name):
985+
def get_gainmap(self):
986986
"""Get the image gainmap, if any.
987987
988988
Get the gainmap associated with this image, or None for no gainmap.
@@ -1234,7 +1234,7 @@ def __array__(self, dtype=None, copy=None):
12341234
import numpy as np
12351235

12361236
# we always generate a new image, so if copy is False, we can't work
1237-
if not copy:
1237+
if copy is False:
12381238
raise ValueError
12391239

12401240
arr = (

tests/helpers/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
JPEG_FILE = os.path.join(IMAGES, "sample.jpg")
1111
WEBP_FILE = os.path.join(IMAGES, "sample.webp")
1212
SVG_FILE = os.path.join(IMAGES, "logo.svg")
13+
UHDR_FILE = os.path.join(IMAGES, "ultra-hdr.jpg")
1314

1415

1516
# an expanding zip ... if either of the args is a scalar or a one-element list,

tests/images/ultra-hdr.jpg

1.14 MB
Loading

tests/test_image.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pyvips
44
import pytest
5-
from helpers import JPEG_FILE
5+
from helpers import JPEG_FILE, UHDR_FILE, skip_if_no
66

77

88
class TestImage:
@@ -393,3 +393,26 @@ def test_from_PIL(self):
393393
assert im.height == pim.height
394394
assert im.min() == 0
395395
assert im.max() == 0
396+
397+
@skip_if_no('uhdrload')
398+
@pytest.mark.skipif(not pyvips.at_least_libvips(8, 18),
399+
reason="requires libvips >= 8.18")
400+
def test_gainmap(self):
401+
def crop_gainmap(image):
402+
gainmap = image.get_gainmap()
403+
404+
if gainmap:
405+
new_gainmap = gainmap.crop(0, 0, 10, 10)
406+
image = image.copy()
407+
image.set_type(pyvips.GValue.image_type,
408+
"gainmap", new_gainmap)
409+
410+
return image
411+
412+
image = pyvips.Image.new_from_file(UHDR_FILE)
413+
image = crop_gainmap(image)
414+
buf = image.write_to_buffer(".jpg")
415+
new_image = pyvips.Image.new_from_buffer(buf, "")
416+
new_gainmap = new_image.get_gainmap()
417+
418+
assert new_gainmap.width == 10

0 commit comments

Comments
 (0)