开始
This commit is contained in:
Executable
+10
@@ -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)
|
||||
Reference in New Issue
Block a user