Skip to content

Image.fromarrow minimal example does not work #8907

@ghost

Description

from PIL import Image
import pyarrow as pa
arr = pa.array([0]*(5*5*4), type=pa.uint8())
im = Image.fromarrow(arr, 'RGBA', (5, 5))
  • Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
  • Pillow 11.2.1
  • pyarrow 19.0.1
Traceback (most recent call last):
  File "C:\Users\...\main.py", line 4, in <module>
    im = Image.fromarrow(arr, 'RGBA', (5, 5))
  File "C:\Users\...\AppData\Local\Programs\Python\Python313\Lib\site-packages\PIL\Image.py", line 3373, in fromarrow
    _im = core.new_arrow(mode, size, schema_capsule, array_capsule)
ValueError: Invalid Arrow array mode or size mismatch

Is there any special version required?

Workaround: the following seems to work:

from PIL import Image
import pyarrow as pa

mode = "RGB"
size = (1920, 1080)
img = Image.new(mode, size=size, color="grey")
pa_img_arr = pa.array(img)
pa_img = Image.fromarrow(pa_img_arr, mode, size)
pa_img.save("pa_img.jpg")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions