| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| from pathlib import Path | |
| from zipfile import ZIP_DEFLATED, ZipFile | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--image-dir", required=True) | |
| parser.add_argument("--zip-path", required=True) | |
| args = parser.parse_args() | |
| image_dir = Path(args.image_dir) | |
| images = sorted(image_dir.glob("*.jpg")) + sorted(image_dir.glob("*.png")) | |
| if not images: | |
| raise SystemExit(f"No images found in {image_dir}") | |
| zip_path = Path(args.zip_path) | |
| zip_path.parent.mkdir(parents=True, exist_ok=True) | |
| with ZipFile(zip_path, "w", compression=ZIP_DEFLATED) as zf: | |
| for image in images: | |
| zf.write(image, arcname=image.name) | |
| print(f"Wrote {zip_path} with {len(images)} images") | |
| if __name__ == "__main__": | |
| main() | |