Skip to content

Commit

Permalink
Reducing package file size by reducing screenshot sizes (#119)
Browse files Browse the repository at this point in the history
* Adding some notes on how to reduce image size for screenshots - coming from direct experience with pngquant

* updating bibliography upon executing bookdown::render_book()

---------

Co-authored-by: Marcel Ramos Pérez <[email protected]>
  • Loading branch information
federicomarini and LiNk-NY authored Sep 17, 2024
1 parent 04d4a39 commit 7a1224c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions general-package-development.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Do not use filenames that differ only in case, as not all file systems are case-
### Package size {#package-size}

The source package resulting from running `R CMD build` should occupy less than 5 MB on disk.
If your package includes (e.g. in the vignettes) some screenshots, this limit can be reached quite quickly. Their size can be reduced (often as much as 70%) in a lossy but quality-preserving manner by using tools such as [pngquant](https://pngquant.org/) (available as a command line utility and as a GUI on most systems).

### Check duration {#check-duration}

Expand Down
27 changes: 15 additions & 12 deletions packages.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@ @Manual{R-base
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2022},
year = {2024},
url = {https://www.R-project.org/},
}

@Manual{R-bookdown,
title = {bookdown: Authoring Books and Technical Documents with R Markdown},
author = {Yihui Xie},
year = {2022},
note = {https://github.com/rstudio/bookdown},
year = {2024},
note = {R package version 0.38,
https://pkgs.rstudio.com/bookdown/},
url = {https://github.com/rstudio/bookdown},
}

@Manual{R-knitr,
title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
author = {Yihui Xie},
year = {2022},
note = {R package version 1.41},
year = {2023},
note = {R package version 1.45},
url = {https://yihui.org/knitr/},
}

@Manual{R-rmarkdown,
title = {rmarkdown: Dynamic Documents for R},
author = {JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone},
year = {2022},
note = {https://github.com/rstudio/rmarkdown},
author = {JJ Allaire and Yihui Xie and Christophe Dervieux and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone},
year = {2024},
note = {R package version 2.26,
https://pkgs.rstudio.com/rmarkdown/},
url = {https://github.com/rstudio/rmarkdown},
}

@Book{bookdown2016,
Expand All @@ -35,7 +39,7 @@ @Book{bookdown2016
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2016},
note = {ISBN 978-1138700109},
isbn = {978-1138700109},
url = {https://bookdown.org/yihui/bookdown},
}

Expand All @@ -58,7 +62,6 @@ @InCollection{knitr2014
publisher = {Chapman and Hall/CRC},
year = {2014},
note = {ISBN 978-1466561595},
url = {http://www.crcpress.com/product/isbn/9781466561595},
}

@Book{rmarkdown2018,
Expand All @@ -67,7 +70,7 @@ @Book{rmarkdown2018
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2018},
note = {ISBN 9781138359338},
isbn = {9781138359338},
url = {https://bookdown.org/yihui/rmarkdown},
}

Expand All @@ -77,7 +80,7 @@ @Book{rmarkdown2020
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2020},
note = {ISBN 9780367563837},
isbn = {9780367563837},
url = {https://bookdown.org/yihui/rmarkdown-cookbook},
}

4 changes: 4 additions & 0 deletions shiny-apps.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ To set the name of an Rd document, use the `@name` tag in the Roxygen block:
}
```

Additionally, the vignette of a shiny app package might include some screenshots, either generated manually or programmatically.
If generated manually, developers can use tools such as [pngquant](https://pngquant.org/) (available as a command line utility and as a GUI on most systems) to reduce their size (about 70%) without too much loss of quality.
Programmatically generated screenshots can be realized by means of the [Webshot2](https://cran.r-project.org/package=webshot2) package, using the `webshot2::appshot()` function.

## Review

When reviewing a shiny app package, the reviewer should check that the package
Expand Down

0 comments on commit 7a1224c

Please sign in to comment.