Skip to content

Instantly share code, notes, and snippets.

View wassef911's full-sized avatar
😶‍🌫️
undercover

Wassef Ben Ahmed wassef911

😶‍🌫️
undercover
View GitHub Profile
@wassef911
wassef911 / recursively_compress_image.py
Created April 22, 2024 21:31
useful to run against a media directory to save space... (make sure to experiment with quality kwarg!)
import os
from PIL import Image
def compress_png_in_place(folder_path):
"""
Recursively finds all PNG files in the specified directory, compresses them, and saves them in place.
Args:
folder_path (str): The path to the directory where to start searching and compressing PNG files.