Last active
November 18, 2023 16:55
-
-
Save IamAkshayKaushik/8d458337358968a7cde5a1683443da87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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