This commit is contained in:
2025-08-08 10:38:10 +08:00
commit c7dc4d6c02
114 changed files with 11010 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
from PIL import Image
def allowed_file(filename, allowed_extensions):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in allowed_extensions
def compress_image(image_path, max_size=(1500, 1500), quality=85):
"""压缩图片"""
img = Image.open(image_path)
img.thumbnail(max_size, Image.Resampling.LANCZOS)
img.save(image_path, quality=quality)