This demos shows you how to optimize PNG images with optipng
.
opts_chunk$set(cache = TRUE)
knit_hooks$set(optipng = hook_optipng)
Now we set the chunk option optipng
to a non-NULL
value, e.g. ''
, to activate the hook.
library(methods)
library(ggplot2)
set.seed(123)
qplot(rnorm(1000), rnorm(1000))
Same plot, not optimized:
library(methods)
library(ggplot2)
set.seed(123)
qplot(rnorm(1000), rnorm(1000))
Same plot, most heavily optimized (pass -o7
to optipng
):
library(methods)
library(ggplot2)
set.seed(123)
qplot(rnorm(1000), rnorm(1000))