using ColorTypes, FileIO ]st ImageIO struct PNG{T} data::T end PNG(filename::AbstractString) = read(filename) |> PNG function PNG(img::AbstractMatrix{<:Colorant}) buf = IOBuffer() save(Stream(format"PNG", buf), img) take!(buf) |> PNG end function Base.show(io::IO, ::MIME"image/png", p::PNG) write(io, p.data) flush(io) end hcat( fill(rand(RGB), 240, 100), fill(rand(RGB), 240, 100), fill(rand(RGB), 240, 100) ) |> PNG Base.showable(::MIME"image/svg+xml", ::AbstractMatrix{<:Colorant}) = false function Base.show(io::IO, mime::MIME"image/png", img::AbstractMatrix{<:Colorant}) show(io, mime, PNG(img)) end img = fill(rand(RGB), 240, 300) img[30:180, 50:200] .= rand(RGB) ix = filter(CartesianIndices(img)) do cix i, j = cix.I (i-150)^2 + (j-200)^2 < 80^2 end img[ix] .= rand(RGB) img using Base64 function Base.show(io::IO, ::MIME"text/html", p::PNG) write(io, "") flush(io) end function Base.show(io::IO, mime::MIME"text/html", img::AbstractMatrix{<:Colorant}) show(io, mime, PNG(img)) end img