Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 923 Bytes

035-optipng.md

File metadata and controls

44 lines (30 loc) · 923 Bytes

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(1000), rnorm(1000))

plot of chunk use-optipng

Same plot, not optimized:

library(methods)
library(ggplot2)
set.seed(123)
qplot(rnorm(1000), rnorm(1000))

plot of chunk no-optipng

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

library(methods)
library(ggplot2)
set.seed(123)
qplot(rnorm(1000), rnorm(1000))

plot of chunk optipng-o7