Skip to content

Commit e370c8d

Browse files
authored
Support reading from an IOBuffer (#180)
Fixes JuliaIO/FileIO.jl#174
1 parent 9249ab3 commit e370c8d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/libmagickwand.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ function readimage(wand::MagickWand, stream::Vector{UInt8})
287287
nothing
288288
end
289289

290+
readimage(wand::MagickWand, stream::IOBuffer) = readimage(wand, stream.data)
291+
290292
function writeimage(wand::MagickWand, filename::AbstractString)
291293
status = ccall((:MagickWriteImages, libwand), Cint, (Ptr{Cvoid}, Ptr{UInt8}, Cint), wand, filename, true)
292294
status == 0 && error(wand)

test/constructed_images.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ mutable struct TestType end
229229
@test size(img) == (2,2)
230230
end
231231

232+
Sys.isunix() && @testset "Reading from an IOBuffer (issue https://github.com/JuliaIO/FileIO.jl/issues/174)" begin
233+
fn = joinpath(workdir, "2by2.png")
234+
io = open(fn)
235+
arr = read(io)
236+
close(io)
237+
iobuffer = IOBuffer(arr)
238+
img = ImageMagick.load(iobuffer)
239+
@test size(img) == (2,2)
240+
end
241+
232242
@testset "show(MIME)" begin
233243
Ar = rand(UInt8, 3, 2, 2)
234244
Ar[1] = typemax(eltype(Ar))

0 commit comments

Comments
 (0)