Save to file

You can specify the file type when you come to save

    image1.save("C:/MyDirectory/myimage.jpg"), quality=95)

Output as a byte array

import io
from PIL import Image

    image1_byte_array = io.BytesIO()
    image1.save(image1_byte_array, format='JPG')
    image1_byte_array = image1_byte_array.getvalue()
    return image1_byte_array

#You could then save this byte array toi a file using:
    with open("C:/MyDirectory/myimage.jpg"), "wb") as file1:
        file1.write(image1_byte_array)

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *