Skip to content

Commit 52bb204

Browse files
authored
pass extra save_stream keywords to image2wand (#199)
Similar to the save_ method for filename, this PR passes extra keywords to image2wand. An example of this is a stream gif saving with fps keyword. Also fixes a FileIO depwarn in the tests.
1 parent 47fdb39 commit 52bb204

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/ImageMagick.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ end
166166

167167
# This differs from `save_` for files because this is primarily used
168168
# by IJulia, and we want to restrict large images to make display faster.
169-
function save_(s::Stream, img, permute_horizontal=true; mapi = clamp01nan, quality = nothing)
170-
wand = image2wand(img, mapi, quality, permute_horizontal)
169+
function save_(s::Stream, img, permute_horizontal=true; mapi = clamp01nan, quality = nothing, kwargs...)
170+
wand = image2wand(img, mapi, quality, permute_horizontal; kwargs...)
171171
blob = getblob(wand, formatstring(s))
172172
write(stream(s), blob)
173173
end

test/constructed_images.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ mutable struct TestType end
214214
orig_img = ImageMagick.load(joinpath(workdir, "2by2.png"))
215215
fn = joinpath(workdir, "2by2_fromstream.png")
216216
open(fn, "w") do f
217-
ImageMagick.save(Stream(format"PNG", f), orig_img)
217+
ImageMagick.save(Stream{format"PNG"}(f), orig_img)
218218
end
219219
img = ImageMagick.load(fn)
220220
@test img == orig_img
@@ -279,6 +279,15 @@ mutable struct TestType end
279279
readimage(wand, fn)
280280
resetiterator(wand)
281281
@test ImageMagick.getimagedelay(wand) == 50
282+
283+
fn = joinpath(workdir, "animated.gif")
284+
open(fn, "w") do io
285+
ImageMagick.save(FileIO.Stream{format"GIF"}(io), A, fps=2)
286+
end
287+
wand = MagickWand()
288+
readimage(wand, fn)
289+
resetiterator(wand)
290+
@test ImageMagick.getimagedelay(wand) == 50
282291
end
283292

284293
@testset "ImageMeta" begin

test/images/test-exiforientation.zip

4.29 KB
Binary file not shown.

test/readremote.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ end
160160
end
161161

162162
@testset "EXIF orientation" begin
163-
url = "http://magnushoff.com/assets/test-exiforientation.zip"
164-
fn = joinpath(workdir, "test-exiforientation.zip")
165-
download(url, fn)
163+
# downloaded from http://magnushoff.com/assets/test-exiforientation.zip
164+
fn = joinpath(@__DIR__, "images", "test-exiforientation.zip")
166165
first_img = true
167166
r = ZipFile.Reader(fn)
168167
local img0

0 commit comments

Comments
 (0)