# Download image from the web
frink <- image_read("https://jeroenooms.github.io/images/frink.png")
worldcup_frink <- image_fill(frink, "orange", "+100+200", 30000)
image_write(worldcup_frink, "output.png")
# 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://jeroenooms.github.io/images/example.webp", "example.webp")
image_read(webp::read_webp("example.webp"))
curl::curl_download("http://jeroenooms.github.io/images/tiger.svg", "tiger.svg")
image_read(rsvg::rsvg("tiger.svg"))
# Create thumbnails from GIF
banana <- image_read("https://jeroenooms.github.io/images/banana.gif")
length(banana)
image_average(banana)
image_flatten(banana)
image_append(banana)
image_append(banana, stack = TRUE)
# Append images together
image_append(image_scale(c(image_append(banana[c(1,3)], stack = TRUE), frink)))
# Combine with another image
logo <- image_read("https://www.r-project.org/logo/Rlogo.png")
oldlogo <- image_read("https://developer.r-project.org/Logo/Rlogo-3.png")
# Create morphing animation
both <- image_scale(c(oldlogo, logo), "400")
image_average(image_crop(both))
image_animate(image_morph(both, 10))
# Basic compositions
image_composite(banana, image_scale(logo, "300"))
# Break down and combine frames
front <- image_scale(banana, "300")
background <- image_scale(logo, "400")
frames <- lapply(as.list(front), function(x) image_flatten(c(background, x)))
image_animate(image_join(frames))
Run the code above in your browser using DataLab