Closed brshallo closed 4 years ago
The pagedown::print_chrome()
step acts funny when called in a function environment (seems to not always work when flipbook has objects other than what is being revealed). Have not tested whether this is specific to flipbookr
or a general problem with pagedown
.
However the following modification seems to fix things so that pagedown::print_chrome(flipbook_filepath)
can more generally run within a function:
flipbook_to_gif <- function(flipbook_filepath,
density = 100,
delay = 1,
env_pdf = rlang::caller_env()){
filepath <- fs::path_ext_remove(flipbook_filepath)
filepath_pdf <- fs::path_ext_set(filepath, "pdf")
filepath_gif <- fs::path_ext_set(filepath, "gif")
env_pdf$flipbook_filepath <- flipbook_filepath
with(env_pdf, pagedown::chrome_print(flipbook_filepath))
images <- magick::image_read_pdf(filepath_pdf, density = density)
magick::image_write_gif(images,
filepath_gif,
delay = delay)
}
I updated the source code at the link above and also added a third example that runs this on the "minimal-flipbook.Rmd" (so can see it looks pretty good outside of just simple flipbookr::chunk_reveal()
examples).
There's now guidance about how to create a gif preview in the template.
After adding in the css noted in #21 , the following function should create a gif (as well as html and pdf outputs) of your flipbook via
flipbookr
-->pagedown
-->magick
.See notes and reproducible examples at brshallo/flipbookr-gifs-examples.
E.g. now below is built through
flipbookr
rather thanflair
(per recommendation of @kbodwin )