Debian Codegraph @

man/shrink_images.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/image.R
3 \name{shrink_images}
4 \alias{shrink_images}
5 \title{Shrink images to a maximum width}
6 \usage{
7 shrink_images(
8 width = 800,
9 dir = ".",
10 files = all_files("[.](png|jpe?g|webp)$", dir),
11 tinify = FALSE
12 )
13 }
14 \arguments{
15 \item{width}{The desired maximum width of images.}
16
17 \item{dir}{The directory of images.}
18
19 \item{files}{A vector of image file paths. By default, this is all
20 \file{.png}, \file{.jpeg}, and \file{.webp} images under \code{dir}.}
21
22 \item{tinify}{Whether to compress images using \code{\link[=tinify]{tinify()}}.}
23 }
24 \description{
25 Use \code{\link[magick:image_resize]{magick::image_resize()}} to shrink an
26 image if its width is larger than the value specified by the argument
27 \code{width}, and optionally call \code{\link[=tinify]{tinify()}} to compress it.
28 }
29 \examples{\dontshow{if (xfun::loadable('magick')) \{}
30 f = xfun:::all_files("[.](png|jpe?g)$", R.home("doc"))
31 file.copy(f, tempdir())
32 f = file.path(tempdir(), basename(f))
33 magick::image_info(magick::image_read(f)) # some widths are larger than 300
34 xfun::shrink_images(300, files = f)
35 magick::image_info(magick::image_read(f)) # all widths <= 300 now
36 file.remove(f)
37 \dontshow{\}}
38 }