Skip to content Skip to sidebar Skip to footer

Python - How To Save A List As An Image?

I generate a regular list. Is it possible to save this list as a JPEG image or PNG or whatever so that I can open the image and look at it? I am currently trying to figure it out u

Solution 1:

Here is one of the possible solutions:

  1. Create an empty image object using: Image.new(mode, size, color)

  2. Modify the image object to contain the data from the "list"

  3. Save the image

E.g.:

new_img = Image.new("L", (NEW_X_SIZE, NEW_Y_SIZE), "white")
new_img.putdata(new_img_list)
new_img.save('out.tif')

Post a Comment for "Python - How To Save A List As An Image?"