图片尺寸调整
在浏览器中将图片调整为任意尺寸 — 无需上传到服务器。
常见问题
代码实现
from PIL import Image
# Open and resize to exact dimensions
img = Image.open("input.jpg")
resized = img.resize((800, 600), Image.LANCZOS)
resized.save("output.jpg")
# Resize to percentage (50%)
width, height = img.size
half = img.resize((width // 2, height // 2), Image.LANCZOS)
half.save("half_size.jpg")
# Resize maintaining aspect ratio (max width 800)
img.thumbnail((800, 800), Image.LANCZOS)
img.save("thumbnail.jpg")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.