Reputation: 59
I have not been able to control the text colour in the image_annotate function of package magick in R.
I have tried the R color name "white" and the hexadecimal colour for white "#FFFFFF" and in both cases the text returned is black.
Other text controls are honored such as font size.
The example below illustrates the issue. When I view the output in the RStudio Plot window the text is black. I get the same results when I write the image to a PNG file
I am using the R version 4.2.2, RStudio Build 676, and Magick version in R 2.7.3
This code demonstates the issue.
library(magick)
height <- 100
width <- 80
X <- array(
runif(height * width * 3, min = 0, max = 255),
dim = c(height, width, 3)
)
img <- magick::image_read(X / 255) %>% magick::image_scale("500x400")
img <- magick::image_annotate(img, text = "Example", gravity = "northeast", location = "+50+50", font = "times", size ="20", color = "white")
print(img)
image_write(img, path = "c:/temp/ouput.png")
Thank you
Upvotes: 1
Views: 264