Set some default options for tinify()
in the global environment, so it is no
longer necessary to explicitly provide each argument with every call of
tinify()
.
If called without any arguments, tinify_defaults()
will print
the current default options set to the console.
tinify_defaults(overwrite, suffix, quiet, return_path, resize)
Boolean, defaults to FALSE
. By default, tinify will create
a new file with the suffix '_tiny' and preserve the original file. Set
TRUE
to instead overwrite the original file, with the same file name.
String, defaults to "_tiny"
. By default, tinify will create a
new file with the suffix '_tiny' and preserve the original file. Provide a
new character string here to change the suffix from '_tiny' to your own
choice. Empty strings (""
) are not accepted. suffix
is ignored when
overwrite
is set to TRUE
.
Boolean, defaults to FALSE
. By default, tinify provides details
on file names, amount of file size reduction (% and Kb), and the number of
TinyPNG API calls made this month. If set to TRUE
, tinify displays no
messages as it shrinks files.
String or NULL
, optional. One of "proj
", "rel
", "abs
", or
"all
". If "proj
", will return the file path of the newly tinified image
file relative to the Rstudio project directory (looking for an .Rproj file).
If no project can be identified, returns NA
. If "rel
", will return the
file path of the newly tinified image file, relative to the current
working directory at the time tinify()
is called. If "abs
", will return
the absolute file path of the newly tinified image file. If "all
", will
return a named list with all file paths. Set to NULL
to stop returning a
file path.
Named list or NULL
, optional. A named list with the elements method
as
a string, and width
and/or height
as numerics. Please note you can only
reduce an image's dimensions and make an image smaller with TinyPNG API, not
make an image larger. Method must be set to one of "scale", "fit", "cover",
or "thumb". If using "scale", you only need to provide width
OR height
,
not both. If using any other method, you must supply both a width
AND
height
. See https://tinypng.com/developers/reference#resizing-images and
the examples for more. Set to NULL
to stop resizing.
tinify()
to shrink image filesizes
tinify_key()
to set a default TinyPNG.com API key
if (FALSE) {
tinify_defaults(quiet = TRUE, suffix = "_small")
# show current defaults set
tinify_defaults()
#> Tinify 'overwrite' set to: FALSE
#> Tinify 'suffix' set to: "_small"
#> Tinify 'quiet' set to: FALSE
#> Tinify 'return_path' set to: No return
#> Tinify 'resize' set to: No resize
}