If an image isn’t properly closed after opening with Pillow, it’s likely because you’re trying to pass the opened image itself without operating on it. Images are lazily loaded until they’re operated on, which can cause multiple being opened to overlap each other in physical memory. To solve this, load images and operate on them one at a time.

Source#

Pillow docs