0

Imagine I have an image called img.jpeg and I want to make half of it transparent.

I tried, without success, the code below:

library(jpeg)
img <- readJPEG("img.jpeg")
img[1:100, ] <- NA  # all the NA pixels should be transparent
writeJPEG(img, "img_1.jpeg", bg = "transparent")

Any solution?

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
mat
  • 2,412
  • 5
  • 31
  • 69

1 Answers1

2

As far as I know, the .jpeg format does not support transparency.

So I would try using another format like .png, .tif or others.

You may have a a look at this post.

YesThatIsMyName
  • 1,585
  • 3
  • 23
  • 30