...理想情况下,使用PNG图像文件,如果不是JPEG.我可以加载一个flie
library(png)
img = readPNG("chart.png")
Run Code Online (Sandbox Code Playgroud)
但我被困在那里.目标是在图像上键入"Hello world"并保存.
谢谢.
MrF*_*ick 11
我认为这应该工作得很好
library(png)
#read file
img<-readPNG("33.png")
#get size
h<-dim(img)[1]
w<-dim(img)[2]
#open new file for output
png("out.png", width=w, height=h)
par(mar=c(0,0,0,0), xpd=NA, mgp=c(0,0,0), oma=c(0,0,0,0), ann=F)
plot.new()
plot.window(0:1, 0:1)
#fill plot with image
usr<-par("usr")
rasterImage(img, usr[1], usr[3], usr[2], usr[4])
#add text
text(.5,.5, "hello", cex=5, col=rgb(.2,.2,.2,.7))
#close image
dev.off()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19481 次 |
| 最近记录: |