Skip to content

Instantly share code, notes, and snippets.

@matt-dray
Created December 23, 2019 12:08
Show Gist options
  • Save matt-dray/d44b715f9fe06949cc4cc0352aa61d06 to your computer and use it in GitHub Desktop.
Save matt-dray/d44b715f9fe06949cc4cc0352aa61d06 to your computer and use it in GitHub Desktop.
Use {magick} to read 'before' and 'after' images to a gif
library(magick)
before <- image_read("~/Desktop/before.png")
before <- image_crop(before, "815x300-80-200")
after <- image_crop(image_read("~/Desktop/after.png"))
after <- image_crop(after, "815x300-80-200")
# To morph
# frames <- image_morph(c(before, after, before), frames = 20)
# image_animate(frames)
# To animate
img <- c(before, after)
ani <- image_animate(image_scale(img, "x200"), fps = 1, dispose = "previous")
image_write(ani, "~/Desktop/animation.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment