Daft icon indicating copy to clipboard operation
Daft copied to clipboard

bug: exception when showing image in jupyter notebook

Open chuanlei-coding opened this issue 9 months ago • 6 comments

Describe the bug

Image

To Reproduce

No response

Expected behavior

No response

Component(s)

Expressions

Additional context

No response

chuanlei-coding avatar Mar 26 '25 08:03 chuanlei-coding

Image

chuanlei-coding avatar Mar 26 '25 14:03 chuanlei-coding

When you do a url_download, the returned type is a binary which is why it shows as a base64 string.

rchowell avatar Mar 26 '25 14:03 rchowell

The error looks like your jpeg has an unsupported encoding 'Rgba8' but we do support this with "rgba". Could you try url_download(url).image.decode('RGBA')

rchowell avatar Mar 26 '25 14:03 rchowell

@chuanlei-coding please let me know if the suggestion works for you, thank you!

rchowell avatar Mar 26 '25 16:03 rchowell

@chuanlei-coding please let me know if the suggestion works for you, thank you!

import daft
df = daft.from_pydict(
        {
            "urls": [
                "https://www.getdaft.io/_static/stairs.png",
            ]
        }
    )
df2 = df.with_column("image", df["urls"].url.download().image.decode())
df2.show()

daft cannot deal with png image currently.

Image

chuanlei-coding avatar Mar 27 '25 06:03 chuanlei-coding

Took a quick look, this bug only happens when we preview images in a notebook. In these cases we were incorrectly encoding images that have an alpha channel as JPEG.

Fix is here https://github.com/Eventual-Inc/Daft/pull/4255

desmondcheongzx avatar Apr 26 '25 00:04 desmondcheongzx

Ran into this today... And you all fixed it pre-emptively already :) good job!

jaychia avatar May 06 '25 20:05 jaychia