R Magick 包中的文本对齐

问题描述 投票:0回答:1

我正在尝试使用 R 中的 magick 包和 image_annotate 将文本与其放置坐标集中对齐...

所以在这个例子中

#Load Graphic
pb<-image_read("https://art.pixilart.com/8c9cffeb529b204.png")
#Place text at central coordinate
image_draw(pb) %>% 
  image_annotate("Centre",location=geometry_point(610.5,610.5), color = "red", size = 50)

“中心”一词的右上角与提供的坐标(大致)对齐。

是否可以设置一个命令(相当于 hjust、vjust 等)来居中对齐文本......

虽然 ImageMagick 可能具有其中一些功能,但看起来并不是所有命令和参数都已移植到 R 包中(尽管我可能遗漏了一些东西)

r imagemagick annotate image-annotations magick
1个回答
0
投票
library(magick)
#> Warning: package 'magick' was built under R version 4.3.2
#> Linking to ImageMagick 6.9.12.98
#> Enabled features: cairo, freetype, fftw, ghostscript, heic, lcms, pango, raw, rsvg, webp
#> Disabled features: fontconfig, x11

#Load Graphic
pb<-image_read("https://art.pixilart.com/8c9cffeb529b204.png")
#Place text at central coordinate
image_draw(pb) |>  
  image_annotate("Centre",
                 color = "red", 
                 size = 50,
                 gravity = "center")

创建于 2024-04-09,使用 reprex v2.0.2

© www.soinside.com 2019 - 2024. All rights reserved.