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

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -