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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -