python-blur-image.py 462 B

12345678910111213141516
  1. from PIL import Image, ImageFilter
  2. import os
  3. img_dir = "C:/python/python-blur-image/"
  4. img_name = 'original.jpg'
  5. img = Image.open(img_dir + img_name)
  6. f, e = os.path.splitext(img_dir + img_name)
  7. blur_img = img.filter(ImageFilter.BLUR)
  8. blur_img.save(f + '_blurred.jpg')
  9. box_blur_img = img.filter(ImageFilter.BoxBlur(7))
  10. box_blur_img.save(f + '_box_blurred.jpg')
  11. gaus_blur_img = img.filter(ImageFilter.GaussianBlur(7))
  12. gaus_blur_img.save(f + '_gaus_blurred.jpg')