Skip to content

Commit

Permalink
fixed IOBuffer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Oskin committed Apr 14, 2020
1 parent 9249ab3 commit 7dd556d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libmagickwand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ function readimage(wand::MagickWand, stream::Vector{UInt8})
nothing
end

readimage(wand::MagickWand, stream::IOBuffer) = readimage(wand, stream.data)

function writeimage(wand::MagickWand, filename::AbstractString)
status = ccall((:MagickWriteImages, libwand), Cint, (Ptr{Cvoid}, Ptr{UInt8}, Cint), wand, filename, true)
status == 0 && error(wand)
Expand Down
10 changes: 10 additions & 0 deletions test/constructed_images.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ mutable struct TestType end
@test size(img) == (2,2)
end

Sys.isunix() && @testset "Reading from an IOBuffer (issue https://github.com/JuliaIO/FileIO.jl/issues/174)" begin
fn = joinpath(workdir, "2by2.png")
io = open(fn)
arr = read(io)
close(io)
iobuffer = IOBuffer(arr)
img = ImageMagick.load(iobuffer)
@test size(img) == (2,2)
end

@testset "show(MIME)" begin
Ar = rand(UInt8, 3, 2, 2)
Ar[1] = typemax(eltype(Ar))
Expand Down

0 comments on commit 7dd556d

Please sign in to comment.