Skip to content

Commit

Permalink
try to use pngquant to compress vignette images on cran
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Feb 22, 2024
1 parent 03e1150 commit 4031834
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ jobs:
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install pngquant
if: runner.os == 'Linux'
run: |
sudo apt-get install -y pngquant
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
Expand Down
16 changes: 13 additions & 3 deletions vignettes/children/chunk_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ img {
</style>

```{r chunk_options, include=FALSE}
if (requireNamespace("pkgdown", quietly = TRUE) && pkgdown::in_pkgdown()) {
in_pkgdown = requireNamespace("pkgdown", quietly = TRUE) && pkgdown::in_pkgdown()

# image dimensions
if (in_pkgdown) {
tiny_width = 5.5
tiny_height = 3 + 2/3
small_width = med_width = 6.75
Expand All @@ -25,12 +28,13 @@ if (requireNamespace("pkgdown", quietly = TRUE) && pkgdown::in_pkgdown()) {
large_width = 5.5
large_height = 2/3
}

knitr::opts_chunk$set(
fig.width = small_width,
fig.height = small_height
)
if (requireNamespace("ragg", quietly = TRUE)) {

# graphics device
if (requireNamespace("ragg", quietly = TRUE) && in_pkgdown) {
knitr::opts_chunk$set(
dev = "ragg_png"
)
Expand All @@ -40,4 +44,10 @@ if (requireNamespace("ragg", quietly = TRUE)) {
dev.args = list(type = "cairo")
)
}

# png compression for CRAN
if (!in_pkgdown) {
knitr::knit_hooks$set(pngquant = knitr::hook_pngquant)
knitr::opts_chunk$set(pngquant = "--speed=1 --quality=50")
}
```

0 comments on commit 4031834

Please sign in to comment.