Is it possible to insert external images into a Powerpoint with officer
without changing the image dimensions?
This is the code I have now where x
is an rpptx
object:
library(officer)
image_url <- "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/768px-Instagram_logo_2016.svg.png"
t_file <- tempfile(pattern = "logo_", fileext = ".png")
download.file(image_url, destfile = t_file)
x <- x %>%
ph_with(value = external_img(t_file), location = ph_location(left = 9.4, top = 4.6))
This will change the dimensions of the image to 4x3 inches (the default for ph_location()
).
I know you can use external R packages to get image metadata then pass this to the function so the actual image dimensions are used, but I don't want to add any more external R package dependencies.