I am trying to extract specific color channels from an RGBA pngs, and re-combine them so they contain only that channel-specific information + the alpha/matte layer. After a lot of trial and error (the documentation unfortunately wasn't specific on how to handle RGBA with image_combine), I finally came up with this solution:
frink <- image_read("https://jeroen.github.io/images/frink.png")
r <- magick::image_channel(frink, "red")
a <- magick::image_channel(frink, "alpha")
rrra_data = image_data(c(r,r,r,a), channels="rgba")
image_read(rrra_data)
I'm sure there is a simpler solution without going through image_data/image_read?