Reputation: 647
I would like to create a 1x1 pixel transparent png file in R. Is there any way to do so or do i have to "copy" a premade 1x1 pixel png?
I've tryed
empty_frame = imfill(x = 1, y = 1, z = 1, val = "transparent", dim = NULL)
but this does not create a transparent pixel but a 1x1 white pixel.
I need the 1x1 pixel .png file as a placeholder in case there are no data to be plotted.
Upvotes: 2
Views: 1298
Reputation: 66880
One way would be using png::writePNG
:
png::writePNG(array(0, dim = c(1,1,4)), "pixel.png")
This creates a transparent 1x1 pixel (with 4 channels set at zero, for each of RGB and alpha), which I confirmed by opening it up in GIMP.
Upvotes: 9