How do I close an image opened in Pillow?

Solution 1:

With Image.close().

You can also do it in a with block:

with Image.open('test.png') as test_image:
    do_things(test_image)

An example of using Image.close():

test = Image.open('test.png')
test.close()