Skip to content

Commit 6b493ae

Browse files
committed
Improve sizing of screenshot to closely match others
1 parent 55a92c5 commit 6b493ae

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
-147 KB
Loading
-140 KB
Loading

tools/gallery-screenshot.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ if (xfun::file_ext(image_path) != "png") {
1717
stop("First argument must be a .png image path to create.")
1818
}
1919
url <- args[2]
20+
width <- if (is.na(args[3])) 1440 else as.numeric(args[3])
21+
height <- if (is.na(args[4])) 900 else as.numeric(args[4])
22+
message("==> Creating screenshot of ", url, " and saving to ", image_path)
23+
png <- webshot2::webshot(url, image_path, vwidth = width, vheight = height)
24+
if (Sys.which("optipng") != "") {
25+
message("==> Shrinking image with optipng")
26+
webshot2::shrink(png)
27+
}
2028

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

0 commit comments

Comments
 (0)