Skip to content

new_from_array(): propagate interpretation - #1430

Merged
jcupitt merged 1 commit into
masterfrom
new_from_array-propagate-interpretation
Oct 21, 2026
Merged

jcupitt merged 1 commit into
masterfrom
new_from_array-propagate-interpretation

Conversation

@jcupitt

@jcupitt jcupitt commented Oct 21, 2026

Copy link
Copy Markdown
Member

also send interpretation into array interfaces

thanks BSAIPF

see #1429

also send interpretation into array interfaces

thanks BSAIPF

see #1429

@kleisauke kleisauke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think this only affects cases where obj.__array__() is backed by an __array_interface__ attribute, since interpretation isn't used otherwise.

@jcupitt

jcupitt commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

Oh hmm, perhaps the:

        if isinstance(obj, list):

case could pass interpretation along as well?

@jcupitt

jcupitt commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

I had a quick look and adding interpretation to new_from_list is not a trivial change. Let's leave it for another PR.

@jcupitt
jcupitt merged commit 9699ee2 into master Oct 21, 2026
12 checks passed
@jcupitt
jcupitt deleted the new_from_array-propagate-interpretation branch October 21, 2026 11:31
@kleisauke

Copy link
Copy Markdown
Member

Indeed, interpretation is only used by:

pyvips/pyvips/vimage.py

Lines 539 to 543 in b243fff

if interpretation is not None:
if interpretation == 'auto':
interpretation = _guess_interpretation(bands, format)
im = im.copy(interpretation=interpretation)

as documented here:

pyvips/pyvips/vimage.py

Lines 463 to 475 in b243fff

interpretation (str, optional): **Ignored for list inputs** The
libvips interpretation of the array. If None, the
interpretation defaults to the pyvips one for
`Image.new_from_memory`.
If 'auto', a heuristic is used to determine a best-guess
interpretation as defined in the `_guess_interpretation`
function.
Must be one of None, 'auto', 'error', 'multiband', 'b-w',
'histogram', 'xyz', 'lab', 'cmyk', 'labq', 'rgb', 'cmc', 'lch',
'labs', 'srgb', 'yxy', 'fourier', 'rgb16', 'grey16', 'matrix',
'scrgb', or 'hsv'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants