resmush_url {resmush} | R Documentation |
Optimize an online file
Description
Optimize and download an online image using the reSmush.it API.
Usage
resmush_url(
url,
outfile = file.path(tempdir(), basename(url)),
overwrite = FALSE,
progress = TRUE,
report = TRUE,
qlty = 92,
exif_preserve = FALSE
)
Arguments
url |
url or a vector of urls pointing to hosted image files. reSmush can optimize the following image files:
|
outfile |
Path or paths where the optimized files would be store in
your disk. By default, temporary files (see |
overwrite |
Logical. Should |
progress |
Logical. Display a progress bar when needed. |
report |
Logical. Display a summary report of the process in the console. See also Value. |
qlty |
Only affects |
exif_preserve |
Logical. Should the
Exif information (if any) deleted?
Default is to remove it (i.e. |
Value
Writes on disk the optimized file if the API call is successful. In all cases, a (invisible) data frame with a summary of the process is returned as well.
If any value of the vector outfile
is duplicated, resmush_url()
would
rename the output with a suffix _01. _02
, etc.
See Also
reSmush.it API docs.
Other functions for optimizing:
resmush_dir()
,
resmush_file()
Examples
# Base url
base_url <- "https://raw.githubusercontent.com/dieghernan/resmush/main/inst/"
png_url <- paste0(base_url, "/extimg/example.png")
resmush_url(png_url)
# Several urls
jpg_url <- paste0(base_url, "/extimg/example.jpg")
summary <- resmush_url(c(png_url, jpg_url))
# Returns an (invisible) data frame with a summary of the process
summary
# Display with png
if (require("png", quietly = TRUE)) {
my_png <- png::readPNG(summary$dest_img[1])
grid::grid.raster(my_png)
}
# Use with jpg and parameters
resmush_url(jpg_url)
resmush_url(jpg_url, qlty = 10)