# NOT RUN {
# Download image from the web
frink <- image_read("https://jeroen.github.io/images/frink.png")
worldcup_frink <- image_fill(frink, "orange", "+100+200", 30000)
image_write(worldcup_frink, "output.png")
# extract raw bitmap array
bitmap <- frink[[1]]
# replace pixels with #FF69B4 ('hot pink') and convert back to image
bitmap[,50:100, 50:100] <- as.raw(c(0xff, 0x69, 0xb4, 0xff))
image_read(bitmap)
# Plot to graphics device via legacy raster format
raster <- as.raster(frink)
par(ask=FALSE)
plot(raster)
# Read bitmap arrays
curl::curl_download("https://www.r-project.org/logo/Rlogo.png", "Rlogo.png")
image_read(png::readPNG("Rlogo.png"))
curl::curl_download("https://jeroen.github.io/images/example.webp", "example.webp")
image_read(webp::read_webp("example.webp"))
curl::curl_download("http://jeroen.github.io/images/tiger.svg", "tiger.svg")
image_read(rsvg::rsvg("tiger.svg"))
# }
Run the code above in your browser using DataLab