JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

[Question] How to render image with image picking from FilePicker() #269

Closed hungpham3112 closed 7 months ago

hungpham3112 commented 9 months ago

Hi, I like the interactive features in PlutoUI.jl. I'm trying to render the image with FilePicker() but the data field is a vector so I don't know how to display the image.

How can I display image in this situation ?

fonsp commented 7 months ago

Hey! Sorry for the late response, this will work:

# ╔═╡ d59d5f7c-887e-11ee-0fde-e1d5501026dd
using PlutoUI

# ╔═╡ 86b30519-56e1-483c-986d-f48508fb024b
@bind image_data FilePicker()

# ╔═╡ 51125f6a-48e2-4154-8d4a-271e808de083
image_data

# ╔═╡ 5f039984-2e73-40a4-9101-1c4ae16788c7
begin
    path = tempname() * image_data["name"]
    write(path, image_data["data"])
end

# ╔═╡ 1883ebae-9086-47ac-9dca-534010fc7885
LocalResource(path)