Description Usage Arguments Value Examples
View source: R/compress_images.R
Minify size of images located in a directory and output results in another directory.
You will be able to use this function only if
the program 'node.js' is installed on your machine,
the command compress_images_install()
has been executed once
on your machine (it installs a set of "npm" packages).
1 2 3 4 5 6 7 8 9 | compress_images(
input,
output = NULL,
verbose = TRUE,
overwrite = FALSE,
jpg_quality = "75",
png_quality = "20-50",
gif_colors = "64"
)
|
input, output |
input and output directories |
verbose |
should a log be printed in the console, default to TRUE. |
overwrite |
logical; should existing destination files be overwritten? |
jpg_quality |
Scale quantization tables to adjust image quality. Quality is "0" (worst) to "100" (best); default is "75". |
png_quality |
defined as |
gif_colors |
Reduce the number of distinct colors in each output GIF to |
a data.frame with details about input files and compressed files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(minimage)
library(locatexec)
was_avail <- compress_images_available()
if(exec_available("node") && exec_available("npm")){
if(!was_avail)
compress_images_install(force = TRUE)
# generate dest folder
new_dir <- tempfile()
dir.create(new_dir)
# run compression
z <- compress_images(system.file(package = "minimage", "test-files"), new_dir)
print(z)
if(!was_avail)
compress_images_uninstall()
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.