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

Fails with WSLtty #63

Closed
montyvesselinov opened this issue Jan 12, 2022 · 8 comments · Fixed by #64
Closed

Fails with WSLtty #63

montyvesselinov opened this issue Jan 12, 2022 · 8 comments · Fixed by #64

Comments

@montyvesselinov
Copy link

The test problem fails under Win11 WSLtty terminal. Testing the package fails as well.

julia> using Images, TestImages, ImageInTerminal

julia> testimage("cameraman")
512×512 Array{Gray{N0f8},2} with eltype Gray{N0f8}:
Error showing value of type Matrix{Gray{N0f8}}:
ERROR: KeyError: key :nothing not found
Stacktrace:
  [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
    @ Base .\dict.jl:481
  [2] _parse_color
    @ C:\Users\monty\.julia\packages\Crayons\iBicM\src\crayon.jl:143 [inlined]
  [3] #Crayon#1
    @ C:\Users\monty\.julia\packages\Crayons\iBicM\src\crayon.jl:171 [inlined]
  [4] encodeimg(::ImageInTerminal.SmallBlocks, colordepth::ImageInTerminal.TermColor256, img::Matrix{Gray{N0f8}}, maxheight::Int64, maxwidth::Int64)
    @ ImageInTerminal C:\Users\monty\.julia\packages\ImageInTerminal\CyZyh\src\encodeimg.jl:65
  [5] imshow(io::IOContext{Base.TTY}, img::Matrix{Gray{N0f8}}, colordepth::ImageInTerminal.TermColor256, maxsize::Tuple{Int64, Int64})
    @ ImageInTerminal C:\Users\monty\.julia\packages\ImageInTerminal\CyZyh\src\imshow.jl:52
  [6] imshow(io::IOContext{Base.TTY}, img::Matrix{Gray{N0f8}}, colordepth::ImageInTerminal.TermColor256)
    @ ImageInTerminal C:\Users\monty\.julia\packages\ImageInTerminal\CyZyh\src\imshow.jl:44
  [7] show(io::IOContext{Base.TTY}, mime::MIME{Symbol("text/plain")}, img::Matrix{Gray{N0f8}})
    @ ImageInTerminal C:\Users\monty\.julia\packages\ImageInTerminal\CyZyh\src\ImageInTerminal.jl:69
  [8] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:264
  [9] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:508
 [10] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:257
 [11] display(d::REPL.REPLDisplay, x::Any)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:269
 [12] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:328
 [13] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [14] invokelatest
    @ .\essentials.jl:714 [inlined]
 [15] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:291
 [16] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:275
 [17] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:508
 [18] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:273
 [19] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:844
 [20] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [21] invokelatest
    @ .\essentials.jl:714 [inlined]
 [22] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\LineEdit.jl:2493
 [23] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\monty\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\REPL\src\REPL.jl:1230
 [24] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:423

@andferrari
Copy link

Same error with iterm2

@hayesall
Copy link

hayesall commented Jan 17, 2022

This is an error in TestImages.jl, issue should be transferred there.

TestImages.jl looks okay, I thought this might be a ImageIO vs. FileIO problem.

Here's an MRE:

using ImageInTerminal
using TestImages

image = testimage("cameraman.tif");

ImageInTerminal.imshow(image)

with a more-tailored traceback:

ERROR: LoadError: KeyError: key :nothing not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
   @ Base ./dict.jl:481
 [2] _parse_color
   @ ~/.julia/packages/Crayons/iBicM/src/crayon.jl:143 [inlined]
 [3] #Crayon#1
   @ ~/.julia/packages/Crayons/iBicM/src/crayon.jl:171 [inlined]
 [4] encodeimg(::ImageInTerminal.SmallBlocks, colordepth::ImageInTerminal.TermColor256, img::Matrix{ColorTypes.Gray{FixedPointNumbers.N0f8}}, maxheight::Int64, maxwidth::Int64)
   @ ImageInTerminal ~/.julia/packages/ImageInTerminal/CyZyh/src/encodeimg.jl:65
 [5] imshow(io::Base.TTY, img::Matrix{ColorTypes.Gray{FixedPointNumbers.N0f8}}, colordepth::ImageInTerminal.TermColor256, maxsize::Tuple{Int64, Int64})
   @ ImageInTerminal ~/.julia/packages/ImageInTerminal/CyZyh/src/imshow.jl:52
 [6] imshow(io::Base.TTY, img::Matrix{ColorTypes.Gray{FixedPointNumbers.N0f8}}, colordepth::ImageInTerminal.TermColor256)
   @ ImageInTerminal ~/.julia/packages/ImageInTerminal/CyZyh/src/imshow.jl:44
 [7] imshow(::Matrix{ColorTypes.Gray{FixedPointNumbers.N0f8}})
   @ ImageInTerminal ~/.julia/packages/ImageInTerminal/CyZyh/src/imshow.jl:82
 [8] top-level scope
   @ ~/hayesall/iit/debugging.jl:6

@hayesall
Copy link

The toucan image does work:

using ImageInTerminal, TestImages
image = testimage("toucan.png");
ImageInTerminal.imshow(image)

@hayesall
Copy link

hayesall commented Jan 17, 2022

It looks like a problem with the encoding. When images are smaller than the terminal width, things work fine:

using ImageInTerminal, Images, TestImages

colors = colorview(RGB, rand(3, 10, 10));   # <--- Good   ✅, (10 x 10)
toucan = testimage("toucan.png");           # <--- Good   ✅, (150 x 162)
camera = testimage("cameraman.tif");        # <--- Broken ❌, (512 x 512)
coffee = testimage("coffee.png");           # <--- Broken ❌, (400 x 600)

Which means that ImageInTerminal probably shouldn't return Symbol("nothing") here:

# if reached it means that the last character row
# has only the upper pixel defined.
Symbol("nothing")

@t-bltg
Copy link
Member

t-bltg commented Jan 17, 2022

Bug introduced by KristofferC/Crayons.jl#50.

@t-bltg
Copy link
Member

t-bltg commented Jan 17, 2022

Thanks @hayesall for helping us track that down !
New release should be available in about 15/30 min in julia pkg registry.

@KristofferC
Copy link

KristofferC commented Jan 20, 2022

Sorry, I didn't mean to break the API like that. I think I thought that it was just an internal thing.

@t-bltg
Copy link
Member

t-bltg commented Jan 20, 2022

No worries, those happen to us all 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants