# resmush
[](https://CRAN.R-project.org/package=resmush)
[](https://cran.r-project.org/web/checks/check_results_resmush.html)
[](https://CRAN.R-project.org/package=resmush)
[](https://github.com/dieghernan/resmush/actions/workflows/check-full.yaml)
[](https://github.com/dieghernan/resmush/actions/workflows/rhub.yaml)
[](https://app.codecov.io/gh/dieghernan/resmush)
[](https://www.codefactor.io/repository/github/dieghernan/resmush)
[](https://dieghernan.r-universe.dev/resmush)
[](https://doi.org/10.32614/CRAN.package.resmush)
[](https://www.repostatus.org/#active)
[](https://CRAN.R-project.org/package=resmush)
**resmush** is a **R** package that allow users to optimize and compress
images using [**reSmush.it**](https://resmush.it/). reSmush.it is a
free API that provides image optimization, and it has been
implemented on
[WordPress](https://wordpress.org/plugins/resmushit-image-optimizer/),
[Drupal](https://www.drupal.org/project/resmushit) and [many
more](https://resmush.it/tools/).
Some of the features of **reSmush.it** are:
- Free optimization services, no API key required.
- Optimize local and online images.
- Image files supported: `png`, `jpg/jpeg`, `gif`, `bmp`, `tiff`.
- Max image size: 5 Mb.
- Compression via several algorithms:
- [**PNGQuant**](https://pngquant.org/): Strip unneeded chunks from
`png`s, preserving a full alpha transparency.
- [**JPEGOptim**](https://github.com/tjko/jpegoptim)**:** Lossless
optimization based on optimizing the Huffman tables.
- [**OptiPNG**](https://optipng.sourceforge.net/): `png` reducer that
is used by several online optimizers.
## Installation
Install **resmush** from
[**CRAN**](https://CRAN.R-project.org/package=resmush) with:
``` r
install.packages("resmush")
```
You can install the development version of **resmush** from
[GitHub](https://github.com/) with:
``` r
remotes::install_github("dieghernan/resmush")
```
Alternatively, you can install **resmush** using the
[r-universe](https://dieghernan.r-universe.dev/resmush):
``` r
# Install resmush in R:
install.packages("resmush", repos = c(
"https://dieghernan.r-universe.dev",
"https://cloud.r-project.org"
))
```
## Example
Compressing an online `jpg` image:
``` r
library(resmush)
url <- paste0(
"https://raw.githubusercontent.com/dieghernan/",
"resmush/main/img/jpg_example_original.jpg"
)
resmush_url(url, outfile = "man/figures/jpg_example_compress.jpg", overwrite = TRUE)
#> ══ resmush summary ═════════════════════════════════════════════════════════════
#> ℹ Input: 1 url with size 178.7 Kb
#> ✔ Success for 1 url: Size now is 45 Kb (was 178.7 Kb). Saved 133.7 Kb (74.82%).
#> See result in directory 'man/figures'.
```
Original picture (top) 178.7 Kb and optimized picture (bottom) 45 Kb (Compression 74.8%). Click to enlarge.
Low quality image due to a high compression rate.
Hernangómez D (2025). resmush: Optimize and Compress Image Files with reSmush.it. doi:10.32614/CRAN.package.resmush, https://dieghernan.github.io/resmush/.
A BibTeX entry for LaTeX users is @Manual{R-resmush, title = {{resmush}: Optimize and Compress Image Files with {reSmush.it}}, doi = {10.32614/CRAN.package.resmush}, author = {Diego Hernangómez}, year = {2025}, version = {0.2.1}, url = {https://dieghernan.github.io/resmush/}, abstract = {Compress local and online images using the reSmush.it API service
dieghernan |