ITADN

Allow saving as .svgz (Gzip compressed SVG)

#5583Openabhro 创建于 2026-04-07
enhancement
A
abhrocommented
### Feature description When calling `save(filename, fig)`, it should also understand a ".svgz" extension (or a .gz extension in general) and apply a layer of gzip compression on top of the data. ```julia-repl julia> using CairoMakie julia> fig = Figure() julia> save("figure.png", fig) julia> save("figure.svg", fig) CairoMakie.Screen{SVG} julia> save("figure.svg.gz", fig) # ← want this to work ERROR: MethodError: no method matching format2mime(::Type{FileIO.DataFormat{:GZIP}}) The function `format2mime` exists, but no method is defined for this combination of argument types. Stacktrace: [1] save(file::FileIO.File{FileIO.DataFormat{…}, String}, fig::Figure; size::Tuple{Int64, Int64}, resolution::Nothing, backend::Module, update::Bool, screen_config::@Kwargs{}) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:345 [2] save(file::FileIO.File{FileIO.DataFormat{:GZIP}, String}, fig::Figure) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:309 [3] save(filename::String, fig::Figure; args::@Kwargs{}) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:306 [4] save(filename::String, fig::Figure) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:303 julia> save("figure.svgz", fig) # ← and/or this ERROR: MethodError: no method matching format2mime(::Type{FileIO.DataFormat{:UNKNOWN}}) The function `format2mime` exists, but no method is defined for this combination of argument types. Stacktrace: [1] save(file::FileIO.File{FileIO.DataFormat{…}, String}, fig::Figure; size::Tuple{Int64, Int64}, resolution::Nothing, backend::Module, update::Bool, screen_config::@Kwargs{}) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:345 [2] save(file::FileIO.File{FileIO.DataFormat{:UNKNOWN}, String}, fig::Figure) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:309 [3] save(filename::String, fig::Figure; args::@Kwargs{}) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:306 [4] save(filename::String, fig::Figure) @ Makie ~/.julia/packages/Makie/Vn16E/src/display.jl:303 ``` Helpful because often I need to save CairoMakie's beautiful vector graphics, but would like to minimize the storage they end up taking on the drive.
0 条评论