Skip to content

Commit 3e3927c

Browse files
committed
update to 3.1
- new libvips 8.18 docs - fix doc generation - fix warning for new copy arg to __array__ - add a note on PDF load missing in bundled binary - add gainmap support - version bump to 3.1
1 parent 9ad0d2b commit 3e3927c

File tree

9 files changed

+479
-68
lines changed

9 files changed

+479
-68
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## Version 3.0.1 (git master)
1+
## Version 3.1.0 (released 8 December 2025)
22

33
- fix glib DLL name with Conan [boussaffawalid]
4+
- update docs for libvips 8.18 [jcupitt]
5+
- add `get_gainmap()` [jcupitt]
46

57
## Version 3.0.0 (released 28 April 2025)
68

README.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ with:
7878
$ pip install "pyvips[binary]"
7979
8080
This installs a self-contained package with the most commonly needed
81-
libraries. It should just work on most common platforms, including Linux,
82-
Windows and macOS, with x64 and ARM CPUs.
81+
libraries. It should just work on most platforms, including Linux,
82+
Windows and macOS, with 64 and 32 bit x64 and ARM CPUs. Note that this libvips
83+
is missing features like PDF load and OpenSlide support.
8384

84-
If your platform is unsupported or the pre-built binary is
85-
unsuitable, you can install libvips separately instead.
85+
If your platform is unsupported or the pre-built binary is unsuitable, you
86+
can install libvips separately instead.
8687

8788
Local installation
8889
------------------

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
# built documents.
6565
#
6666
# The short X.Y version.
67-
version = u'3.0'
67+
version = u'3.1'
6868
# The full version, including alpha/beta/rc tags.
69-
release = u'3.0.1'
69+
release = u'3.1.0'
7070

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

doc/vimage.rst

Lines changed: 372 additions & 43 deletions
Large diffs are not rendered by default.

pyvips/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ def values_for_enum(gtype):
119119

120120
result = [_to_string(g_enum_class.values[i].value_nick)
121121
for i in range(g_enum_class.n_values)]
122-
# FIXME: remove after https://github.com/libvips/libvips/pull/4520
123-
if 'last' in result:
124-
result.remove('last')
122+
125123
return result
126124

127125

@@ -144,8 +142,7 @@ def enum_dict(gtype):
144142
result = {_to_string(g_enum_class.values[i].value_nick):
145143
g_enum_class.values[i].value
146144
for i in range(g_enum_class.n_values)}
147-
# FIXME: remove after https://github.com/libvips/libvips/pull/4520
148-
result.pop('last', None)
145+
149146
return result
150147

151148

pyvips/enums.py

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ class Interpretation(object):
222222
223223
HSV (str): pixels are HSV
224224
225+
OKLAB (str): pixels are in Oklab colourspace
226+
227+
OKLCH (str): pixels are in Oklch colourspace
228+
225229
"""
226230

227231
ERROR = 'error'
@@ -244,6 +248,8 @@ class Interpretation(object):
244248
MATRIX = 'matrix'
245249
SCRGB = 'scrgb'
246250
HSV = 'hsv'
251+
OKLAB = 'oklab'
252+
OKLCH = 'oklch'
247253

248254

249255
class OperationRelational(object):
@@ -488,6 +494,8 @@ class Access(object):
488494
489495
SEQUENTIAL (str): top-to-bottom reading only, but with a small buffer
490496
497+
SEQUENTIAL_UNBUFFERED (str): deprecated, use :class:`.enums.Access.SEQUENTIAL` instead
498+
491499
"""
492500

493501
RANDOM = 'random'
@@ -843,6 +851,36 @@ class FailOn(object):
843851
WARNING = 'warning'
844852

845853

854+
class ForeignPdfPageBox(object):
855+
"""ForeignPdfPageBox.
856+
857+
Each page of a PDF document can contain multiple page boxes,
858+
also known as boundary boxes or print marks.
859+
860+
Each page box defines a region of the complete page that
861+
should be rendered. The default region is the crop box.
862+
863+
Attributes:
864+
865+
MEDIA (str): media box
866+
867+
CROP (str): crop box
868+
869+
TRIM (str): trim box
870+
871+
BLEED (str): bleed box
872+
873+
ART (str): art box
874+
875+
"""
876+
877+
MEDIA = 'media'
878+
CROP = 'crop'
879+
TRIM = 'trim'
880+
BLEED = 'bleed'
881+
ART = 'art'
882+
883+
846884
class ForeignPpmFormat(object):
847885
"""ForeignPpmFormat.
848886
@@ -949,7 +987,7 @@ class ForeignDzDepth(object):
949987
class ForeignDzContainer(object):
950988
"""ForeignDzContainer.
951989
952-
How many pyramid layers to create.
990+
What container format to use.
953991
954992
Attributes:
955993
@@ -971,6 +1009,12 @@ class RegionShrink(object):
9711009
9721010
How to calculate the output pixels when shrinking a 2x2 region.
9731011
1012+
Images with alpha (see :meth:`.Image.hasalpha`) always shrink with
1013+
:class:`.enums.RegionShrink.MEAN` and pixels scaled by alpha to avoid fringing.
1014+
1015+
Set the image interpretation to :class:`.enums.Interpretation.MULTIBAND` to
1016+
treat all bands equally.
1017+
9741018
Attributes:
9751019
9761020
MEAN (str): use the average
@@ -1223,21 +1267,21 @@ class Kernel(object):
12231267
12241268
Attributes:
12251269
1226-
NEAREST (str): The nearest pixel to the point.
1270+
NEAREST (str): the nearest pixel to the point
12271271
1228-
LINEAR (str): Convolve with a triangle filter.
1272+
LINEAR (str): convolve with a triangle filter
12291273
1230-
CUBIC (str): Convolve with a cubic filter.
1274+
CUBIC (str): convolve with a cubic filter
12311275
1232-
MITCHELL (str): Convolve with a Mitchell kernel.
1276+
MITCHELL (str): convolve with a Mitchell kernel
12331277
1234-
LANCZOS2 (str): Convolve with a two-lobe Lanczos kernel.
1278+
LANCZOS2 (str): convolve with a two-lobe Lanczos kernel
12351279
1236-
LANCZOS3 (str): Convolve with a three-lobe Lanczos kernel.
1280+
LANCZOS3 (str): convolve with a three-lobe Lanczos kernel
12371281
1238-
MKS2013 (str): Convolve with Magic Kernel Sharp 2013.
1282+
MKS2013 (str): convolve with Magic Kernel Sharp 2013
12391283
1240-
MKS2021 (str): Convolve with Magic Kernel Sharp 2021.
1284+
MKS2021 (str): convolve with Magic Kernel Sharp 2021
12411285
12421286
"""
12431287

@@ -1330,7 +1374,9 @@ class ForeignKeep(object):
13301374
13311375
ICC (int): keep ICC metadata
13321376
1333-
OTHER (int): keep other metadata (e.g. PNG comments and some TIFF tags)
1377+
OTHER (int): keep other metadata (e.g. PNG comments)
1378+
1379+
GAINMAP (int): keep the gainmap metadata
13341380
13351381
ALL (int): keep all metadata
13361382
@@ -1342,7 +1388,8 @@ class ForeignKeep(object):
13421388
IPTC = 4
13431389
ICC = 8
13441390
OTHER = 16
1345-
ALL = 31
1391+
GAINMAP = 32
1392+
ALL = 63
13461393

13471394

13481395
class ForeignPngFilter(object):

pyvips/vdecls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,12 @@ def cdefs(features):
455455
456456
'''
457457

458+
if _at_least(features, 8, 18):
459+
code += '''
460+
VipsImage *vips_image_get_gainmap(VipsImage *image);
461+
462+
'''
463+
458464
# we must only define these in API mode ... in ABI mode we need to call
459465
# these things earlier
460466
if features['api']:

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.0.1'
2+
__version__ = '3.1.0'
33

44
__all__ = ['__version__']

pyvips/vimage.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,29 @@ def set_kill(self, kill):
982982

983983
# get/set metadata
984984

985+
def get_gainmap(self, name):
986+
"""Get the image gainmap, if any.
987+
988+
Get the gainmap associated with this image, or None for no gainmap.
989+
After updating the gainmap, use :meth:`.set_type` to update the
990+
`"gainmap"` metadata item.
991+
992+
Returns:
993+
The gainmap image.
994+
995+
Raises:
996+
None
997+
998+
"""
999+
if not at_least_libvips(8, 18):
1000+
return None
1001+
else:
1002+
pointer = vips_lib.vips_image_get_gainmap(self.pointer)
1003+
if pointer == ffi.NULL:
1004+
return None
1005+
else:
1006+
return pyvips.Image(pointer)
1007+
9851008
def get_typeof(self, name):
9861009
"""Get the GType of an item of metadata.
9871010
@@ -1182,13 +1205,15 @@ def tolist(self):
11821205
#
11831206
# return interface
11841207

1185-
def __array__(self, dtype=None):
1208+
def __array__(self, dtype=None, copy=None):
11861209
"""Conversion to a NumPy array.
11871210
11881211
Args:
11891212
dtype (str or numpy dtype, optional) The dtype to use for the
11901213
numpy array. If None, the default dtype of the image is used
11911214
as defined the global `FORMAT_TO_TYPESTR` dictionary.
1215+
copy (bool, optional) If True, always copy the data; if None, copy
1216+
if required; if False, never copy.
11921217
11931218
Returns:
11941219
numpy.ndarray: The array representation of the image.
@@ -1208,6 +1233,10 @@ def __array__(self, dtype=None):
12081233
"""
12091234
import numpy as np
12101235

1236+
# we always generate a new image, so if copy is False, we can't work
1237+
if not copy:
1238+
raise ValueError
1239+
12111240
arr = (
12121241
np.frombuffer(self.write_to_memory(),
12131242
dtype=FORMAT_TO_TYPESTR[self.format])

0 commit comments

Comments
 (0)