wch / webshot

Take screenshots of web pages from R
http://wch.github.io/webshot/
228 stars 40 forks source link

Switch from external ImageMagick/GraphicsMagick programs to magick package #30

Open wch opened 7 years ago

maelle commented 6 years ago

I was also wondering whether you'd consider returning a magick image object instead of saving the screenshot to disk.

I tend to use this wrapper

magick_webshot <- function(...){
  path <- paste0(tempfile(), ".png")
  webshot::webshot(..., file = path)
  webshot <- magick::image_read(path)
  file.remove(path)
  webshot
}

This way I can render the screenshot directly in an RMarkdown document. This was inspired by the rtweet::tweet_shot function that actually uses webshot.

wch commented 6 years ago

@maelle That does sound useful. It could be an option to webshot(), instead of a new function.

wch commented 6 years ago

Also, using webshot() in an Rmarkdown document should just work. That's how it's done in the vignette.

Source: https://raw.githubusercontent.com/wch/webshot/master/vignettes/intro.Rmd

And the result: https://cran.r-project.org/web/packages/webshot/vignettes/intro.html

maelle commented 6 years ago

ooooh I had no idea sorry! 🙈 Thanks!