From b78da20d04e59f4250268ab762c36c19c8a469d8 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 19 Mar 2019 12:40:40 +0100 Subject: [PATCH 1/2] add support for gif mime --- src/animation.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/animation.jl b/src/animation.jl index e8017ff1..59de784e 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -106,6 +106,14 @@ function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) end +# Only gifs can be shown via image/gif +Base.showable(::MIME"image/gif", agif::AnimatedGif) = file_extension(agif.filename) == "gif" + +function Base.show(io::IO, ::MIME"image/gif", agif::AnimatedGif) + write(io, read(agif.filename)) +end + + # ----------------------------------------------- function _animate(forloop::Expr, args...; callgif = false) From 19fba27951137c7f04de6976510f36500ee11474 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 19 Mar 2019 14:23:25 +0100 Subject: [PATCH 2/2] don't read into a buffer first --- src/animation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/animation.jl b/src/animation.jl index 59de784e..4f9ff6da 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -110,7 +110,7 @@ end Base.showable(::MIME"image/gif", agif::AnimatedGif) = file_extension(agif.filename) == "gif" function Base.show(io::IO, ::MIME"image/gif", agif::AnimatedGif) - write(io, read(agif.filename)) + open(fio-> write(io, fio), agif.filename) end