Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to display images. #60

Closed
karlwessel opened this issue Apr 5, 2020 · 8 comments
Closed

Add support to display images. #60

karlwessel opened this issue Apr 5, 2020 · 8 comments
Labels
almost closed other packages Integration with other Julia packages
Milestone

Comments

@karlwessel
Copy link
Contributor

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.

@fonsp
Copy link
Owner

fonsp commented Apr 5, 2020

Thanks! I'll look into it.

@fonsp
Copy link
Owner

fonsp commented Apr 5, 2020

I added support for PNG, JPG and SVG 🌈

image

@karlwessel
Copy link
Contributor Author

Works nicely, thank you!

@karlwessel
Copy link
Contributor Author

karlwessel commented Aug 11, 2020

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.

@fonsp fonsp reopened this Aug 12, 2020
@fonsp fonsp added this to the 🧭 v0.12 milestone Aug 12, 2020
@fonsp fonsp added the bug Something isn't working label Aug 12, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 13, 2020

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.

@fonsp
Copy link
Owner

fonsp commented Aug 13, 2020

I've submitted an issue to ImageIO

JuliaIO/ImageIO.jl#6

@fonsp fonsp added the other packages Integration with other Julia packages label Aug 16, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 19, 2020

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

@fonsp
Copy link
Owner

fonsp commented Aug 19, 2020

I offered a fix: JuliaImages/ImageShow.jl#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
almost closed other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

2 participants