computerschaf/static/img/fotos/thumbnail.py

13 lines
402 B
Python
Raw Permalink Normal View History

2023-02-23 00:46:24 +01:00
#!/usr/bin/python3
import sys
import pathlib
import subprocess
SIZES = [(320, 240), (480, 360), (640, 480)]
image_path = pathlib.Path(sys.argv[1])
for width, height in SIZES:
thumb_name = image_path.with_name(f"{image_path.stem}_{height}.webp")
print(f"Generating {width}x{height} at {thumb_name}")
subprocess.run(["convert", str(image_path), "-resize", f"{width}x{height}", thumb_name])