From 99605baf663e84da5abc6d7e25b9788d24bfc0bb Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 16 Mar 2021 10:31:06 +0800 Subject: [PATCH] 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. --- src/ImageMagick.jl | 4 ++-- test/constructed_images.jl | 11 ++++++++++- test/images/test-exiforientation.zip | Bin 0 -> 4391 bytes test/readremote.jl | 5 ++--- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 test/images/test-exiforientation.zip diff --git a/src/ImageMagick.jl b/src/ImageMagick.jl index e65b70e..3a4b934 100755 --- a/src/ImageMagick.jl +++ b/src/ImageMagick.jl @@ -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 diff --git a/test/constructed_images.jl b/test/constructed_images.jl index 22da7e4..082488a 100755 --- a/test/constructed_images.jl +++ b/test/constructed_images.jl @@ -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 @@ -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 diff --git a/test/images/test-exiforientation.zip b/test/images/test-exiforientation.zip new file mode 100644 index 0000000000000000000000000000000000000000..b4fe46ec7f4dbc082be728714d1ee08773027316 GIT binary patch literal 4391 zcmeH~don15<2~;=ZRfk4owM`#{qgx;?U4{(2@nV*05bP0 zMLeu17+B8(0$D>qAbyY>h`1wIZC{`-8YKvV(4IP=IT3PL2n6OG1^)5xM@ZU(0C5M2 zJN3W^M3r)5U60kLsxlYAD`{ zxB-P+!?D|x4FZu}{B_-G66RZm!-%jHOy5EMPxB+xgRhM~1@=N&k@rw_Dg1YXm{yQU zm83l$*kYb&)8BYN!u9z<-*TVT=$P-7)HFNn7d&upwC&c57Y%+W zYn8@nd^2jM%^pUzCRmC$^SWDFk>gbFt_K}Sy7=xsyD}GkU9LB;T_}7_Ly}RfRQIS@ za*&gfm(|mQ9uvn8oxRE8xBr%12q3$3VLlJYU=XMVh<~$7V==p`fXw2=581^EA7VqG zV0B$PT_^&9h%toUd&^dgN(-LBg@D6(lgaFBGC49muCBeV zZaqD&y*<6Xdeywu)q46h=1gWNFT-NfCWZxrkxxJm7vxiX7z~MEiHyz;ZMv57aLDRl z?NumkE$w*)+`tG<0Jj}SkRUL_PngL2iK{3{!^`&K2;NZ4?f*11H?2lpMw26AQ?s*U zqq8ZLXud7(LK(g|QNmhBtzd$=`&&9gq} zU00)J^7);|K7MI>;G(eW*!;|gC!Z8{h0oPD-2%@f8#T7(swG=C8w2F&DkyY&Hyj=dQ0Dp~t%rze4ER>c0!_*XiFDNc7&%5N~ zy^pwmumAAm;P}Yv7h`MX#AGGqMP(>CX=gIerDmf&95K#V2e;1t_P(xXk9xKJXEH85 zE^IxmAMj{U8JV@stKvXsVT=3K{ZH!fugc9%Cd(Q9^@Y*wl%?iX6E-!QNWCU+9QNhq zSmi5qY~3t#>|GY^c^#Yid4jzSDx4BNDRUeeGPl~TqhQW|{T>W{4y{g*H9IaUU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