I want to keep transparent background at my 'image' variable.
If I write into a file, image looks fine. I mean image has a transparent background.
with urllib.request.urlopen(request) as response:
imgdata = response.read()
with open("temp_png_file.png", "wb") as output:
output.write(imgdata)
However, if I keep the image data in BytesIO, transparent background becomes a black background.
with urllib.request.urlopen(request) as response:
imgdata = response.read()
ioFile = io.BytesIO(imgdata)
img = Image.open(ioFile)
img.show()
(Above code piece, img.show line shows an image with black background.)
How can I keep a transparent image object in img variable ?