library(tidyverse)
library(magick)
#> Linking to ImageMagick 6.9.9.14
#> Enabled features: cairo, freetype, fftw, ghostscript, lcms, pango, rsvg, webp
#> Disabled features: fontconfig, x11
img_file <- tempfile(fileext = ".png")
download.file("https://hoxo-m.com/img/team/makiyama.png", destfile = img_file, mode = "wb")
img <- image_read(img_file)
img_bw <- image_convert(img, type = "grayscale")
img_small <- image_resize(img_bw, "32x32")
img_big <- image_resize(img_bw, "640x640")
img <- image_composite(img_big, img_small, offset = "+304+304")
w <- 640
h <- 640
zoom <- 1 + 0.4 * 0:50
geometries <- sprintf("%fx%f%+f%+f",
w / zoom, h / zoom,
(w - w / zoom) / 2, (h - h / zoom) / 2)
imgs <- lapply(geometries, image_crop, image = img)
animation <- imgs %>%
image_join() %>%
image_resize("160x160") %>%
image_animate(fps = 25)
print(animation)
#> # A tibble: 51 x 7
#> format width height colorspace matte filesize density
#> <chr> <int> <int> <chr> <lgl> <int> <chr>
#> 1 gif 160 160 sRGB FALSE 0 72x72
#> 2 gif 160 160 sRGB TRUE 0 72x72
#> 3 gif 160 160 sRGB TRUE 0 72x72
#> 4 gif 160 160 sRGB TRUE 0 72x72
#> 5 gif 160 160 sRGB TRUE 0 72x72
#> 6 gif 160 160 sRGB TRUE 0 72x72
#> 7 gif 160 160 sRGB TRUE 0 72x72
#> 8 gif 160 160 sRGB TRUE 0 72x72
#> 9 gif 160 160 sRGB TRUE 0 72x72
#> 10 gif 160 160 sRGB TRUE 0 72x72
#> # ... with 41 more rows
Created on 2018-11-23 by the reprex package (v0.2.1)