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
  • 22,030
  • 6
  • 65
  • 95
mat
  • 2,141
  • 4
  • 21
  • 60

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,458
  • 3
  • 22
  • 28