Skip to content

Commit

Permalink
Improve sizing of screenshot to closely match others
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv committed Oct 3, 2024
1 parent 55a92c5 commit 6b493ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/gallery/websites/website-mickael.canouil.fr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions tools/gallery-screenshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ if (xfun::file_ext(image_path) != "png") {
stop("First argument must be a .png image path to create.")
}
url <- args[2]
width <- if (is.na(args[3])) 1440 else as.numeric(args[3])
height <- if (is.na(args[4])) 900 else as.numeric(args[4])
message("==> Creating screenshot of ", url, " and saving to ", image_path)
png <- webshot2::webshot(url, image_path, vwidth = width, vheight = height)
if (Sys.which("optipng") != "") {
message("==> Shrinking image with optipng")
webshot2::shrink(png)
}

# taking the size from previous image
example <- "docs/gallery/dashboards/housing-market-dashboard.png"
if (!is.na(args[3])) example <- args[3]
infos <- magick::image_read(example) |> magick::image_info()
webshot2::webshot(url, image_path, vwidth = infos$width, vheight = infos$height)

0 comments on commit 6b493ae

Please sign in to comment.