Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 官员:如何用它插入图片';s原始宽度和高度_R_Officer - Fatal编程技术网

R 官员:如何用它插入图片';s原始宽度和高度

R 官员:如何用它插入图片';s原始宽度和高度,r,officer,R,Officer,就像在标题中一样:我想将几个外部图像添加到我的.docx文档中。但是当使用body\u add\u img时,我需要指定宽度和高度。有没有办法将它们设置为要添加的原始图像的宽度和高度 为什么我需要这个?我的图像(大约50幅)具有所有不同的宽度和高度,因此手动将它们的宽度和高度放入(大约50幅)body\u add\u img调用会很痛苦。如果您的图像是png,您可以png::readPNG以像素为单位获得宽度和高度,然后除以DPI以英寸为单位获得尺寸。(用您的DPI替换300) dpiinfo

就像在标题中一样:我想将几个外部图像添加到我的
.docx
文档中。但是当使用
body\u add\u img
时,我需要指定宽度和高度。有没有办法将它们设置为要添加的原始图像的宽度和高度


为什么我需要这个?我的图像(大约50幅)具有所有不同的宽度和高度,因此手动将它们的宽度和高度放入(大约50幅)
body\u add\u img
调用会很痛苦。

如果您的图像是png,您可以
png::readPNG
以像素为单位获得宽度和高度,然后除以DPI以英寸为单位获得尺寸。(用您的DPI替换300)

dpi
info
dpi <- 300
img_size <- dim(png::readPNG('image/path/here.png'))/dpi