This example shows the PNG savings in CRAN packages using tinyimg::tinypng(). The data is collected via the GitHub Action workflow in https://github.com/yihui/tinyimg/actions/workflows/cran-png-savings.yaml.
Download data:
cran_png = read.csv(
'https://github.com/yihui/tinyimg/releases/latest/download/cran-png-savings.csv'
)
Total original PNG size in all packages is 5.8 Gb, and total optimized PNG sizes are 3.9 Gb (lossless) and 3 Gb (lossy).
Transform data:
cran_png = subset(cran_png, orig_size > 0)
png_data = reshape(
cran_png, varying = c("opt_size", "lossy_size"), v.names = "opt_size",
timevar = "type", times = c("Lossless", "Lossy"), direction = "long"
)
png_data = within(png_data, {
orig_mb = round(orig_size / 2^20, 4)
opt_mb = round(opt_size / 2^20, 4)
})
Draw a scatter plot of original vs optimized (loseless and lossy) PNG sizes:
library(gglite)
png_data |>
g2(opt_mb ~ orig_mb, color = ~ type) |>
mark_point(tooltip = list(title = 'package')) |>
axis_x(title = 'Original PNG size (MB)') |>
axis_y(title = 'Optimized PNG size (MB)') |>
interact('brushFilter')
You may brush the points to zoom in, and double click to zoom out.