# Write an image
x <- image_read("https://jeroen.github.io/images/frink.png")
image_write(x, "frink.png")
# Pass some properties to PNG encoder
defines <- c("png:compression-filter" = "1", "png:compression-level" = "0")
image_set_defines(x, defines)
image_write(x, "frink-uncompressed.png")
# Unset properties
defines[1:2] = NA
image_set_defines(x, defines)
image_write(x, "frink-final.png")
# Compare size and cleanup
file.info(c("frink.png", "frink-uncompressed.png", "frink-final.png"))
unlink(c("frink.png", "frink-uncompressed.png", "frink-final.png"))
Run the code above in your browser using DataLab