ImageShow.jl icon indicating copy to clipboard operation
ImageShow.jl copied to clipboard

html show method: use IOContext from original renderer

Open fonsp opened this issue 1 year ago • 1 comments

Hey! I was working on https://discourse.julialang.org/t/making-images-as-big-as-possible-max-width-in-pluto-notebooks/115003/14 and noticed that when the HTML show method is used from ImageShow, any properties from the io context are ignored.

In particular, it is not possible to use the :full_fidelity property to control the HTML show method.

You can see this in this example:

Before

julia> using Colors, ImageShow, ImageIO

julia> img = rand(Gray, 2000, 2000);

julia> sprint() do io
                  show(io, MIME"text/html"(), img)
              end
249546

julia> sprint() do io
                  show(IOContext(io, :full_fidelity=>true), MIME"text/html"(), img)
              end |> length
249546

(the two outputs are the same)

After

julia> using Colors, ImageShow, ImageIO

julia> img = rand(Gray, 2000, 2000);

julia> sprint() do io
           show(io, MIME"text/html"(), img)
       end |> length
249658

julia> sprint() do io
           show(IOContext(io, :full_fidelity=>true), MIME"text/html"(), img)
       end |> length
5345654

(different, because full_fidelity has an effect)

fonsp avatar Jun 08 '24 15:06 fonsp

Hey @johnnychen94 ! Could you take a look at the two open PRs?

fonsp avatar Jun 11 '24 07:06 fonsp