【发布时间】:2021-08-28 15:04:09
【问题描述】:
是否可以在不更改图像尺寸的情况下使用officer 将外部图像插入到 Powerpoint 中?
这是我现在拥有的代码,其中x 是rpptx 对象:
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))
这会将图像的尺寸更改为 4x3 英寸(ph_location() 的默认值)。
我知道您可以使用外部 R 包获取图像元数据,然后将其传递给函数,以便使用实际图像尺寸,但我不想添加任何更多外部 R 包依赖项。
【问题讨论】: