Skip to content

Instantly share code, notes, and snippets.

@IamAkshayKaushik
Last active November 18, 2023 16:55
Show Gist options
  • Save IamAkshayKaushik/8d458337358968a7cde5a1683443da87 to your computer and use it in GitHub Desktop.
Save IamAkshayKaushik/8d458337358968a7cde5a1683443da87 to your computer and use it in GitHub Desktop.
# https://youtu.be/fKl2JW_qrso?si=eKlsoKSAgjYUVQ39
import time
import concurrent.futures
from PIL import Image, ImageFilter
img_names = [] # list of images with path
t1 = time.perf_counter()
size = (1200, 1200)
def process_image(img_name):
img = Image.open(img_name)
img = img.filter(ImageFilter.GaussianBlur(15))
img.thumbnail(size)
img.save(f'processed/{img_name}')
print(f'{img_name} was processed...')
with concurrent.futures.ProcessPoolExecutor() as executor:
executor.map(process_image, img_names)
t2 = time.perf_counter()
print(f'Finished in {t2-t1} seconds')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment