I was trying to save bytes as an image, but it doesn't seem to be working.
here is what I tried:
from PIL import Image
from io import BytesIO
image = open('D:\pythonScreenshots\screenshot1.jpg', 'rb')
a = image.read()
stream = BytesIO(a)
image = Image.open(stream).convert("RGBA")
stream.close()
photo_path = 'D:\pythonScreenshots\screenshot2.jpg'
image.save(photo_path)
But I get an error saying that it cannot write mode RGBA as JPEG, so i guess this method works only with pngs? If so, is there any other way to do it with jpeg images?
CodePudding user response:
try with "RGB" only, "RGBA" has a alpha channel that jpg not supports