HOME/Articles/

pil example negate all bmp (snippet)

Article Outline

Python pil example 'negate all bmp'

Modules used in program:

  • import glob
  • import PIL.ImageOps

python negate all bmp

Python pil example: negate all bmp

from PIL import Image
import PIL.ImageOps
import glob
for f in glob.glob('./*.bmp'):
    image = Image.open(f).convert("RGB")
    inverted_image = PIL.ImageOps.invert(image)
    inverted_image.save(f)