Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] savefig("foo.svgz") (gzip-compressed SVG) #4916

Open
stevengj opened this issue Apr 8, 2024 · 1 comment
Open

[FR] savefig("foo.svgz") (gzip-compressed SVG) #4916

stevengj opened this issue Apr 8, 2024 · 1 comment

Comments

@stevengj
Copy link
Contributor

stevengj commented Apr 8, 2024

According to the docs, most of the graphical backends support SVG output, but it looks like a lot of them don't support SVGZ (which is simply gzip-compressed SVG).

Matplotlib supports SVGZ and it seems like it would be quite easy to implement similar support for any backend that supports SVG, simply by piping the SVG output through a GZipStream from GZip.jl.

For example, it seems like this works already:

using Plots, GZip
p = plot(...)
gzopen(io -> show(io, "image/svg+xml", p), "bar.svgz", "w") # save as bar.svgz

For a typical plot line plot, e.g. plot(rand(100)) or plot(rand(10^4)), I get compression ratios around 50%.

@stevengj
Copy link
Contributor Author

stevengj commented Apr 8, 2024

This stackoverflow discussion claims that the need for SVGZ is greatly reduced by modern web servers that can compress on the fly, but the responses in the thread dispute this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant