-
Notifications
You must be signed in to change notification settings - Fork 11
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 missing stream kwargs & functionality for MIME #7
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
==========================================
- Coverage 50.00% 48.00% -2.00%
==========================================
Files 1 1
Lines 20 25 +5
==========================================
+ Hits 10 12 +2
- Misses 10 13 +3
Continue to review full report at Codecov.
|
(@v1.5) pkg> activate asdfasdf
(asdfasdf) pkg> add Images https://github.com/JuliaIO/ImageIO.jl#ib/fix_mime
julia> using Images
julia> i = Gray.(rand(4,4))
julia> show(stdout, MIME("image/png"), i)
[ Info: Precompiling ImageIO [82e4d734-157c-48bb-816b-45c225c6df19]
Errors encountered while saving nothing.
All errors:
===========================================
MethodError: no method matching permutedims!(::Array{Gray{Float64},2}, ::Tuple{Int64,Int64})
Closest candidates are:
permutedims!(::Array{T,N}, ::StridedArray{T, N}, ::Any) where {T, N} at multidimensional.jl:1394
permutedims!(::Any, ::AbstractArray, ::Any) at permuteddimsarray.jl:194
===========================================
ArgumentError: Package ImageMagick not found in current path:
- Run `import Pkg; Pkg.add("ImageMagick")` to install the ImageMagick package.
===========================================
MethodError: no method matching save(::FileIO.Stream{FileIO.DataFormat{:PNG},Base.TTY}, ::Array{Gray{Float64},2}; mapi=ImageShow.var"#14#16"())
Closest candidates are:
save(::FileIO.File{FileIO.DataFormat{:PNG}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:5 got unsupported keyword argument "mapi"
save(::FileIO.File{FileIO.DataFormat{:SVG}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:15 got unsupported keyword argument "mapi"
save(::FileIO.File{FileIO.DataFormat{:PDF}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:25 got unsupported keyword argument "mapi"
...
===========================================
Fatal error:
ERROR: MethodError: no method matching permutedims!(::Array{Gray{Float64},2}, ::Tuple{Int64,Int64})
Closest candidates are:
permutedims!(::Array{T,N}, ::StridedArray{T, N}, ::Any) where {T, N} at multidimensional.jl:1394
permutedims!(::Any, ::AbstractArray, ::Any) at permuteddimsarray.jl:194
Stacktrace:
[1] handle_error(::MethodError, ::FileIO.Stream{FileIO.DataFormat{:PNG},Base.TTY}) at /home/fons/.julia/packages/FileIO/DzfYr/src/error_handling.jl:82
[2] handle_exceptions(::Array{Any,1}, ::String) at /home/fons/.julia/packages/FileIO/DzfYr/src/error_handling.jl:77
[3] save(::FileIO.Formatted, ::Any; options::Base.Iterators.Pairs{Symbol,ImageShow.var"#14#16",Tuple{Symbol},NamedTuple{(:mapi,),Tuple{ImageShow.var"#14#16"}}}) at /home/fons/.julia/packages/FileIO/DzfYr/src/loadsave.jl:217 [4] show(::Base.TTY, ::MIME{Symbol("image/png")}, ::Array{Gray{Float64},2}; minpixels::Int64, maxpixels::Int64, mapi::Function) at /home/fons/.julia/packages/ImageShow/9kpaq/src/showmime.jl:43
[5] show(::Base.TTY, ::MIME{Symbol("image/png")}, ::Array{Gray{Float64},2}) at /home/fons/.julia/packages/ImageShow/9kpaq/src/showmime.jl:28
[6] top-level scope at REPL[8]:1 |
But it's not supposed to work if only Images and ImageIO are installed right? |
Ah ok.. I actually don't know whether we need the permute for the IJulia/Pluto use-case.. Would you mind trying again? |
Same setup as before, output: julia> show(stdout, MIME("image/png"), i)
julia> repr(MIME("image/png"), i)
Errors encountered while saving nothing.
All errors:
===========================================
type GenericIOBuffer has no field lock
===========================================
ArgumentError: Package ImageMagick not found in current path:
- Run `import Pkg; Pkg.add("ImageMagick")` to install the ImageMagick package.
===========================================
MethodError: no method matching save(::FileIO.Stream{FileIO.DataFormat{:PNG},Base.GenericIOBuffer{Array{UInt8,1}}}, ::Array{Gray{Float64},2}; mapi=ImageShow.var"#14#16"())
Closest candidates are:
save(::FileIO.File{FileIO.DataFormat{:PNG}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:5 got unsupported keyword argument "mapi"
save(::FileIO.File{FileIO.DataFormat{:SVG}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:15 got unsupported keyword argument "mapi"
save(::FileIO.File{FileIO.DataFormat{:PDF}}, ::Any) at /home/fons/.julia/packages/FileIO/DzfYr/src/mimesave.jl:25 got unsupported keyword argument "mapi"
...
===========================================
Fatal error:
ERROR: type GenericIOBuffer has no field lock
Stacktrace:
[1] handle_error(::ErrorException, ::FileIO.Stream{FileIO.DataFormat{:PNG},Base.GenericIOBuffer{Array{UInt8,1}}}) at /home/fons/.julia/packages/FileIO/DzfYr/src/error_handling.jl:82
[2] handle_exceptions(::Array{Any,1}, ::String) at /home/fons/.julia/packages/FileIO/DzfYr/src/error_handling.jl:77
[3] save(::FileIO.Formatted, ::Any; options::Base.Iterators.Pairs{Symbol,ImageShow.var"#14#16",Tuple{Symbol},NamedTuple{(:mapi,),Tuple{ImageShow.var"#14#16"}}}) at /home/fons/.julia/packages/FileIO/DzfYr/src/loadsave.jl:217
[4] show(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/png")}, ::Array{Gray{Float64},2}; minpixels::Int64, maxpixels::Int64, mapi::Function) at /home/fons/.julia/packages/ImageShow/9kpaq/src/showmime.jl:43
[5] show at /home/fons/.julia/packages/ImageShow/9kpaq/src/showmime.jl:28 [inlined]
[6] __binrepr(::MIME{Symbol("image/png")}, ::Array{Gray{Float64},2}, ::Nothing) at ./multimedia.jl:159
[7] _binrepr at ./multimedia.jl:0 [inlined]
[8] #repr#1 at ./multimedia.jl:147 [inlined]
[9] repr(::MIME{Symbol("image/png")}, ::Array{Gray{Float64},2}) at ./multimedia.jl:147
[10] top-level scope at REPL[5]:1
julia> stdout.lock
ReentrantLock(nothing, Base.GenericCondition{Base.Threads.SpinLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), 0) Note that When calling |
I'm out of my depth here. Not worked with MIME etc before. If you see how to fix this, I think that might be the fastest way to a fix. |
Thanks for your help! I'm a little scared to jump into ImageIO's internals but I will keep it in mind. |
Perhaps @johnnychen94 or @SimonDanisch might be able to give guidance on a fix? |
(also see JuliaImages/ImageShow.jl#25) |
maybe: JuliaIO/PNGFiles.jl#19 |
I'd like to write a test case - in which repository do I do that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a clear view on how to fix the issue raised by @fonsp yet, probably I can take a deeper look this weekend. (We are busy at hosting Juliacon for CN community this week :D)
We can also add a short-circuit permute_horizontal=false && mapi == identity
case to avoid memory allocation. And for cases that we must make a copy, I've made suggestions as comments.
@fonsp can you try this PR again with PNGFiles master (given JuliaIO/PNGFiles.jl#19 is now merged) |
@fonsp just a friendly ping |
I'll rebase this to collaborate with JuliaIO/PNGFiles.jl#27 |
I've rebased this in #15 so close this one. |
Candidate fix for #6
@fonsp can you check whether this fixes your issue?