22 lines
695 B
Python
22 lines
695 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Generate `images/manifest.json` from the files present in the images/ folder.
|
|
Run this in the project root to refresh the manifest after adding/removing photos.
|
|
"""
|
|
import os
|
|
import json
|
|
|
|
IMAGEDIR = os.path.join(os.path.dirname(__file__), '..', 'images')
|
|
IMAGEDIR = os.path.abspath(IMAGEDIR)
|
|
|
|
def main():
|
|
exts = ('.jpg', '.jpeg', '.png', '.webp', '.gif')
|
|
files = [f for f in sorted(os.listdir(IMAGEDIR)) if f.lower().endswith(exts)]
|
|
out = os.path.join(IMAGEDIR, 'manifest.json')
|
|
with open(out, 'w', encoding='utf-8') as fh:
|
|
json.dump(files, fh, indent=2)
|
|
print(f'Wrote {len(files)} entries to {out}')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|