Tools to Work with the 'Splash' JavaScript Rendering Service in R
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
1.0KB

  1. #' Return a image (in JPEG format) of the javascript-rendered page.
  2. #'
  3. #' @md
  4. #' @param quality JPEG quality parameter in range from 0 to 100. Default is quality=75.
  5. #' @inheritParams render_html
  6. #' @inheritParams render_png
  7. #' @export
  8. render_jpeg <- function(splash_obj, url, base_url=NULL, quality=75, width=1024, height=768,
  9. timeout=30, resource_timeout=NULL, wait=0, render_all=FALSE,
  10. proxy, js, js_src, filters, allowed_domains="", allowed_content_types="",
  11. forbidden_content_types="", viewport="1024x768", images, headers, body,
  12. http_method, save_args, load_args) {
  13. res <- httr::GET(splash_url(splash_obj), path="render.jpeg",
  14. encode="json",
  15. query=list(url=url, timeout=timeout, wait=wait, viewport=viewport,
  16. quality=quality, width=width, height=height, render_all=as.numeric(render_all)))
  17. httr::stop_for_status(res)
  18. magick::image_read(httr::content(res, as="raw"))
  19. }