Closed nanxstats closed 1 year ago
By switching to pngquant (lossy compression) in https://github.com/nanxstats/ggsci/commit/44a8ce1e705bf56dab8750e0da6a7c7a38f90814, I was able to achieve 30Kb per file using dpi=72
and fig.retina=2
with ragg::agg_png
. The README outputs and vignette outputs are ~900Kb each now.
Package builds and checks ok even if pngquant is not installed (just with much larger built vignette size).
The only thing to remember is to have pngquant installed on the R CMD build
machine when submitting to CRAN.
I'd say this solution would scale well - closing this for now.
R has a check note when installed package size is > 5Mb:
The
doc
here is the vignette with the figures embedded. Thehelp
here contains the output figures fromREADME.Rmd
. Since they have roughly the same content, the limit is ~2.4Mb max for each. We should prioritize the README file figure legibility as it's also served on GitHub repo besides CRAN and the pkgdown site.For a PNG-based solution,
ragg::ragg_png()
generates the minimal size PNG files. We have to keepfig.width = 10.6667
andfig.height = 3.3334
. While we are reaching the lower legibility limit when keepingdpi = 72
. Setfig.retina = 1.2
for vignette and setfig.retina = 2
for README. This gives us 2.3 Mb + 2.6 Mb = 4.9 Mb.For a SVG-based solution,
svglite
produces the minimal size SVG files. They are super legible (vector-based) and can dramatically reduce the figure sizes. However, the current code example contains too many data points and generates ~100Kb figures per palette.Conclusion: