This demos shows you how to optimize PNG images with optipng.

library(knitr)
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(1e3), rnorm(1e3))

Same plot, not optimized:


Same plot, most heavily optimized (pass -o7 to optipng):




Try the parsermd package in your browser

Any scripts or data that you put into this service are public.

parsermd documentation built on May 20, 2021, 5:08 p.m.