Nasty Nas’ Nasty Rubdown via `magick`
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We have 2 legends, Biggie Smalls and Nas. At the 1:00 mark, Nasty Nas receives a Nasty Rubdown. Pretty sure this was the inspiration for Boosie’s Wipe Me Down.
I made a .gif version using a pen, a tablet, and command line ‘ImageMagick‘.
But the resulting FPS was slow, so I decided to try out Jeroen’s R
package, magick , to tune settings for the sped up version below.
I could have totally ‘tuned’ these settings in standalone ‘ImageMagick’, but I like the comforting caress of R’s function syntax.
Some of magick’s R bindings can immediately accept a ‘.gif’, so you can do things like
nas_gif_original %>% image_chop(.,'0x10') %>% image_animate(.,fps=10)
There you have it. Biggie, Nas, an enthusiastic head caresser, pngs, and gifs. Brought to you by R
and magick .
A gist to the R script is below.
options(stringsAsFactors = FALSE) | |
library(dplyr) | |
# install.packages('magick') | |
# https://cran.r-project.org/web/packages/magick/vignettes/intro.html | |
library(magick) | |
str(magick::magick_config()) | |
## external command line magick for initial gif | |
# system('magick convert -delay 25 -resize 1000x1000 -shave 100 *.png out.gif') | |
# pre-existing gif | |
dir_file = '~/projects_local/test_magick/data/raw/' | |
list.files(dir_file,full.names = TRUE) | |
nas_gif = list.files(dir_file,full.names = TRUE)[5] %>% image_read | |
image_info(nas_gif) | |
nas_gif %>% print | |
# chop each frame of pre-existing gif | |
nas_chop = image_chop(nas_gif, "0x10") | |
image_info(nas_chop) | |
# speed up fps of chopped gif | |
image_animate(nas_chop,fps=10) %>% print | |
nas_faster = image_animate(nas_chop,fps=10) | |
nas_faster %>% print | |
# ?image_write | |
getwd() | |
dir_out = '~/projects_local/test_magick/output/' | |
image_write(nas_faster, paste0(dir_out,'nas_faster.gif'),format='gif') | |
# doesn't work on windows | |
# image_write(nas_chop, paste0(dir_out,'nas_faster.mpeg'),format='mpeg') |

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.