Search code examples
pythonpython-imaging-libraryglob

How do I edit multiple files in PIL


I was trying to edit alot of images at the same time using pil and python it shows me this error:

list object has no attribute read

my code so far is below

import glob
import PIL
from PIL import Image

image = glob.glob('./*.png')

img = Image.open(image)
img.putalpha(127)
img.save("")

Solution

  • you may try this:

    import glob
    import PIL
    from PIL import Image
    
    for i in glob.glob('./*.png'):
        img = Image.open(i)
        img.putalpha(127)
        img.save("")