Skip to content

Commit

Permalink
pass extra save_stream keywords to image2wand (#199)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johnnychen94 committed Apr 15, 2021
1 parent 395f31e commit 99605ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/ImageMagick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ end

# This differs from `save_` for files because this is primarily used
# by IJulia, and we want to restrict large images to make display faster.
function save_(s::Stream, img, permute_horizontal=true; mapi = clamp01nan, quality = nothing)
wand = image2wand(img, mapi, quality, permute_horizontal)
function save_(s::Stream, img, permute_horizontal=true; mapi = clamp01nan, quality = nothing, kwargs...)
wand = image2wand(img, mapi, quality, permute_horizontal; kwargs...)
blob = getblob(wand, formatstring(s))
write(stream(s), blob)
end
Expand Down
11 changes: 10 additions & 1 deletion test/constructed_images.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ mutable struct TestType end
orig_img = ImageMagick.load(joinpath(workdir, "2by2.png"))
fn = joinpath(workdir, "2by2_fromstream.png")
open(fn, "w") do f
ImageMagick.save(Stream(format"PNG", f), orig_img)
ImageMagick.save(Stream{format"PNG"}(f), orig_img)
end
img = ImageMagick.load(fn)
@test img == orig_img
Expand Down Expand Up @@ -266,6 +266,15 @@ mutable struct TestType end
readimage(wand, fn)
resetiterator(wand)
@test ImageMagick.getimagedelay(wand) == 50

fn = joinpath(workdir, "animated.gif")
open(fn, "w") do io
ImageMagick.save(FileIO.Stream{format"GIF"}(io), A, fps=2)
end
wand = MagickWand()
readimage(wand, fn)
resetiterator(wand)
@test ImageMagick.getimagedelay(wand) == 50
end

@testset "ImageMeta" begin
Expand Down
Binary file added test/images/test-exiforientation.zip
Binary file not shown.
5 changes: 2 additions & 3 deletions test/readremote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ end
end

@testset "EXIF orientation" begin
url = "http://magnushoff.com/assets/test-exiforientation.zip"
fn = joinpath(workdir, "test-exiforientation.zip")
download(url, fn)
# downloaded from http://magnushoff.com/assets/test-exiforientation.zip
fn = joinpath(@__DIR__, "images", "test-exiforientation.zip")
first_img = true
r = ZipFile.Reader(fn)
local img0
Expand Down

0 comments on commit 99605ba

Please sign in to comment.