Skip to content

Preserve interpretation in array fallback conversion - #1429

Closed
BSAIPF wants to merge 1 commit into
libvips:masterfrom
BSAIPF:contrib/fix-array-fallback-interpretation
Closed

BSAIPF wants to merge 1 commit into
libvips:masterfrom
BSAIPF:contrib/fix-array-fallback-interpretation

Conversation

@BSAIPF

@BSAIPF BSAIPF commented Oct 19, 2026

Copy link
Copy Markdown

Image.new_from_array() drops interpretation when it falls back to an object's __array__ method. For example, a float32 PyTorch RGB tensor with interpretation='auto' produces srgb, while passing its NumPy array directly produces scrgb. An explicit interpretation such as lab is also ignored.

Forward interpretation through the fallback call. Add 15 regression/control cases covering array-only objects, RGB and grayscale data, uint8/uint16/float32, and real PyTorch tensors. The tests also check unchanged pixel values and the default interpretation.

Validation on macOS ARM64, Python 3.12.14, libvips 8.18.7 (API mode):

  • New cases against the original implementation: 9 failed, 6 passed.
  • Full pytest -q -ra: 78 passed, no skips (NumPy, Pillow, SciPy and PyTorch installed).
  • flake8 . passed.
  • Both CI mypy commands passed: mypy pyvips/*.pyi --no-error-summary and mypy examples/*.py --no-error-summary.
  • git diff --check passed.

Prepared with Codex assistance.

@kleisauke

Copy link
Copy Markdown
Member

Please do not use LLMs to generate code or PR descriptions when contributing to libvips:
https://github.com/libvips/libvips/blob/master/CONTRIBUTING.md#ai-policy

Evidence

The PR description mentions the use of OpenAI Codex, as confirmed by the audit log:

user_agent	GitHub CLI 2.102.0 Agent/codex

See also: https://agentscan.tools/user/BSAIPF.

@jcupitt

jcupitt commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Hi @BSAIPF,

I made a tiny, non-LLM PR for this fix and credited you:

#1430

jcupitt added a commit that referenced this pull request Oct 21, 2026
also send interpretation into array interfaces

thanks BSAIPF

see #1429
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.

3 participants