Skip to content

Commit

Permalink
for working on windows webshot doesnt like \\
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarty committed Jan 17, 2024
1 parent 4cd0975 commit a239f83
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions R/gt_html_to_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ gt_html_to_raster <- function(filename,
# In is.null(x) || is.na(x) : 'length(x) = 4 > 1' in coercion to 'logical(1)'

dir.create(filename_dir)
file.create(file.path(filename_dir, paste0(filename_only,".png")))
file.create(file.path(filename_dir, paste0(filename_only,".png")) %>% str_replace_all("\\\\", "/"))

suppressWarnings({
webshot2::webshot(url = filename,
file = file.path(filename_dir, paste0(filename_only,".png")),
file = file.path(filename_dir, paste0(filename_only,".png")) %>% str_replace_all("\\\\", "/"),
vheight = height,
vwidth = width,
cliprect = "viewport",
Expand All @@ -64,7 +64,7 @@ gt_html_to_raster <- function(filename,
})

#### Load as raster and image
png_filename <- file.path(filename_dir, paste0(filename_only, ".png"))
png_filename <- file.path(filename_dir, paste0(filename_only, ".png")) %>% str_replace_all("\\\\", "/")

r <- gt_load_png_as_traffic_raster(filename = png_filename,
location = c(latitude, longitude),
Expand All @@ -75,7 +75,7 @@ gt_html_to_raster <- function(filename,
traffic_color_dist_metric = traffic_color_dist_metric)

## Delete png from temp file
unlink(file.path(filename_dir, paste0(filename_only,".png")))
unlink(file.path(filename_dir, paste0(filename_only,".png")) %>% str_replace_all("\\\\", "/"))

return(r)
}
4 changes: 3 additions & 1 deletion R/gt_make_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ gt_make_raster <- function(location,
webshot_delay <- gt_estimate_webshot_delay(height, width, webshot_delay)

## Filename; as html
filename_html <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = ".html")
temp_dir <- tempdir() %>% str_replace_all("\\\\", "/")
filename_html <- tempfile(pattern = "file", tmpdir = temp_dir, fileext = ".html") %>%
str_replace_all("\\\\", "/")

## Make html
gt_make_html(location = location,
Expand Down

0 comments on commit a239f83

Please sign in to comment.