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

Add options to compress output files, e.g. svg.gz and eps.gz #26

Open
HenrikBengtsson opened this issue Feb 22, 2017 · 1 comment
Open

Comments

@HenrikBengtsson
Copy link
Owner

Some image file formats such as EPS, Postscript and SVG can be significantly compressed. It would be handy if one could compress the output files on the fly using, say, gzip compression.

Some ideas:

toSVG("foo", compression = "gzip", { plot(1:100) })
devEval("svg", name="foo", compression = "gzip", { plot(1:100) })

devOptions("svg", compression = "gzip")
toSVG("foo", { plot(1:100) })
devEval("svg", name="foo", { plot(1:100) })

These should then all output a foo.svg.gz file.

@HenrikBengtsson
Copy link
Owner Author

Notes to self:

Graphics devices do not support using a file connection as output, e.g.

> file <- file("foo.png", open = "wb")
> png(filename = file)
Error in png(filename = file) : invalid 'filename' argument

This means that any compression needs to be done on already created image files. This sounds like a task for the DevEvalFileProduct class.

Some devices support compression, e.g.

> args(tiff)
function (filename = "Rplot%03d.tiff", width = 480, height = 480, 
    units = "px", pointsize = 12, compression = c("none", "rle", 
        "lzw", "jpeg", "zip", "lzw+p", "zip+p"), bg = "white", 
    res = NA, ..., type = c("cairo", "Xlib", "quartz"), antialias) 

How should selective compression be done? That is, we typically only want to compress for certain types, e.g.

res <- devEval(c("png", "svg", "x11", "eps")), name = "foo", plot(1:3) })

Could we use a compression = FALSE (none), compression = TRUE (all), compression = c("svg", "eps")(only SVG and EPS extensions), andcompression = NA` (default set of extensions that we typically want to compression; possibly set via an option).

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

No branches or pull requests

1 participant