tinify {xfun} | R Documentation |
Compress PNG/JPEG images with api.tinify.com, and download the compressed images. This function requires R packages curl and jsonlite.
tinify( input, output, quiet = FALSE, force = FALSE, key = getOption("xfun.tinify.key", Sys.getenv("R_XFUN_TINIFY_KEY")), history = getOption("xfun.tinify.history", Sys.getenv("R_XFUN_TINIFY_HISTORY")) )
input |
A vector of input paths of images. |
output |
A vector of output paths or a function that takes |
quiet |
Whether to suppress detailed information about the compression,
which is of the form input.png (10 Kb) ==> output.png (5 Kb, 50%);
compression count: 42. The percentage after |
force |
Whether to compress an image again when it appears to have been
compressed before. This argument only makes sense when the |
key |
The Tinify API key. It can be set via either the global option
|
history |
Path to a history file to record the MD5 checksum of
compressed images. If the checksum of an expected output image exists in
this file and |
You are recommended to set the API key in ‘.Rprofile’ or
‘.Renviron’. After that, the only required argument of this function is
input
. If the original images can be overwritten by the compressed
images, you may either use output = identity
, or set the value of the
history
argument in ‘.Rprofile’ or ‘.Renviron’.
The output file paths.
Tinify API: https://tinypng.com/developers.
The tinieR package (https://github.com/jmablog/tinieR/)
is a more comprehensive implementation of the Tinify API, whereas
xfun::tinify()
has only implemented the feature of shrinking images.
if (interactive()) { f = file.path(R.home("doc"), "html", "logo.jpg") xfun::tinify(f) # remember to set the API key before trying this }