Pluto.jl: Add support to display images.

Created on 5 Apr 2020  路  8Comments  路  Source: fonsp/Pluto.jl

Currently when creating an Image with Images.jl only the Array representation is shown and not the image itself.

I would consider the actual Image the richer representation and therefore the notebook should display it.

This isn't a very pressing matter since one can always easily display it with plot(image) but I wanted to document it here.

almost closed other packages

Most helpful comment

Workaround

You need to install Images, and ImageMagick for it to work. For an example, see:
https://github.com/mitmath/18S191/blob/master/homework/homework1/hw1.jl

All 8 comments

Thanks! I'll look into it.

I added support for PNG, JPG and SVG 馃寛

image

Works nicely, thank you!

At some point showing images stopped working for me. With the code above i get the error

Failed to show value:

MethodError: no method matching save(::IOContext{Base64.Base64EncodePipe}, ::Array{ColorTypes.Gray{Float64},2}, ::Pair{Symbol,ImageShow.var"#14#16"})

Closest candidates are:

save(::IO, ::S; compression_level, compression_strategy, filters, palette) where {T, S<:Union{AbstractArray{T,3}, AbstractArray{T,2} where T}} at /home/karl/.julia/packages/PNGFiles/y75yo/src/io.jl:274

save(!Matched::String, ::S; compression_level, compression_strategy, filters, palette) where {T, S<:Union{AbstractArray{T,3}, AbstractArray{T,2} where T}} at /home/karl/.julia/packages/PNGFiles/y75yo/src/io.jl:242

handle_error(::MethodError, ::FileIO.Stream{FileIO.DataFormat{:PNG},IOContext{Base64.Base64EncodePipe}})@error_handling.jl:82
handle_exceptions(::Array{Any,1}, ::String)@error_handling.jl:77
#save#30(::Base.Iterators.Pairs{Symbol,ImageShow.var"#14#16",Tuple{Symbol},NamedTuple{(:mapi,),Tuple{ImageShow.var"#14#16"}}}, ::typeof(FileIO.save), ::FileIO.Formatted, ::Any)@loadsave.jl:217
#show#13(::Int64, ::Int64, ::Function, ::typeof(show), ::IOContext{Base64.Base64EncodePipe}, ::MIME{Symbol("image/png")}, ::Array{ColorTypes.Gray{Float64},2})@showmime.jl:43
show(::IOContext{Base64.Base64EncodePipe}, ::MIME{Symbol("image/png")}, ::Array{ColorTypes.Gray{Float64},2})@showmime.jl:28
#show_richest#16(::Bool, ::typeof(Main.PlutoRunner.show_richest), ::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any)@PlutoRunner.jl:308
show_richest(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any)@PlutoRunner.jl:274
#sprint_withreturned#15(::IOContext{Base.PipeEndpoint}, ::Int64, ::typeof(Main.PlutoRunner.sprint_withreturned), ::Function, ::Array{ColorTypes.Gray{Float64},2})@PlutoRunner.jl:247
format_output(::Array{ColorTypes.Gray{Float64},2})@PlutoRunner.jl:192
fetch_formatted_result(::Base.UUID, ::Bool)@PlutoRunner.jl:33
top-level scope@none:1
(::Distributed.var"#106#108"{Distributed.CallMsg{:call_fetch}})()@process_messages.jl:294
run_work_thunk(::Distributed.var"#106#108"{Distributed.CallMsg{:call_fetch}}, ::Bool)@process_messages.jl:79
macro expansion@process_messages.jl:294[inlined]
(::Distributed.var"#105#107"{Distributed.CallMsg{:call_fetch},Distributed.MsgHeader,Sockets.TCPSocket})()@task.jl:356

It works fine in the REPL.

I tried running the example again on Pluto v0.5.14, the version where it was originally fixed - it's broken there too:
image

This means that something changed to Images.jl or ImageIO.jl that broke the show method.

I've submitted an issue to ImageIO

https://github.com/JuliaIO/ImageIO.jl/issues/6

Workaround

You need to install Images, and ImageMagick for it to work. For an example, see:
https://github.com/mitmath/18S191/blob/master/homework/homework1/hw1.jl

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jarvist picture jarvist  路  6Comments

aramirezreyes picture aramirezreyes  路  3Comments

karlwessel picture karlwessel  路  4Comments

enuit picture enuit  路  3Comments

MikaelSlevinsky picture MikaelSlevinsky  路  5Comments