python: Convert from PNG to JPG without saving file to disk using PIL -
in program need convert .png
file .jpg
file don't want save file disk. use
>>> pil import imag >>> ima=image.open("img.png") >>> ima.save("ima.jpg")
but saves file disk. dont want save disk have converted .jpg
object. how can it?
you can trying using bytesio io:
from io import bytesio def converttojpeg(im): bytesio() f: im.save(f, format='jpeg') return f.getvalue()
Comments
Post a Comment