Files
singular-particular-space/Images/script-guide.md
JL Kruger e57d2b0a72 Add Images section — hub + 4 collection galleries, wire nav star
- Images/images.html: hub page linking all 4 collections
- Images/wayback.html, nomad-soul.html, myster-wizzard.html, exopraxist.html: collection galleries
- 429 thumbnails (360px) committed across 4 collections
- Gallery renders from baked filename arrays (no on-load fetch)
- Lightbox lazy-fetches FileBrowser for full-res on click, falls back to thumbnail
- .gitignore: allow Images/*/thumbnails/, anchor /GEMINI.md to root only, add .venv/
- index.html: wire Images star node to Images/images.html

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 20:06:19 +02:00

127 lines
2.9 KiB
Markdown

# thumbnail.py — Script Guide
Resizes images to a max width, preserving aspect ratio, no cropping.
Outputs compressed JPEGs to `thumbnails/` subfolders within each collection folder.
---
## Virtual Environment
```bash
python3 -m venv .venv
```
## Requirements
```bash
pip install Pillow
```
---
## Usage
From the repo root:
```bash
python Images/thumbnail.py
```
From inside the Images folder:
```bash
python thumbnail.py
```
---
## What it does
1. Iterates over each collection folder (`WayBack`, `YourNomadSoul`, `MysterWizzard`, `Exopraxist`)
2. Finds all `.jpg`, `.jpeg`, `.png` files (case-insensitive)
3. Resizes any image wider than `MAX_WIDTH` — narrower images are passed through unchanged
4. Converts to RGB JPEG (handles PNG transparency, palette mode, etc.)
5. Saves to `{collection}/thumbnails/{original_stem}.jpg` at quality 85
6. Prints a before/after size summary
---
## Adapting for different uses
### Change the output size
Edit `MAX_WIDTH` at the top of the script:
```python
MAX_WIDTH = 360 # current — web gallery thumbnails
MAX_WIDTH = 880 # larger thumbnails or preview images
MAX_WIDTH = 1920 # full-width web images, still compressed
```
### Change JPEG quality
Edit `QUALITY` at the top:
```python
QUALITY = 85 # current — good balance of size and sharpness
QUALITY = 75 # smaller files, slight quality loss (fine for thumbnails)
QUALITY = 92 # near-lossless, larger files
```
### Change which folders are processed
Edit the `COLLECTIONS` list:
```python
COLLECTIONS = ["WayBack", "YourNomadSoul", "MysterWizzard", "Exopraxist"]
```
Add, remove, or rename entries to match your folder structure.
### Run on a different folder entirely
Change `base` in the `main()` function:
```python
base = Path("/path/to/your/images")
```
Or pass it as a command-line argument — see the adaptation note below.
### Process a flat folder (no subfolders)
Replace the collection loop with a direct scan:
```python
images = sorted(f for f in base.iterdir() if f.suffix in EXTENSIONS and f.is_file())
thumb_dir = base / "thumbnails"
for src in images:
dest = thumb_dir / (src.stem + ".jpg")
make_thumbnail(src, dest)
```
### Accept a path argument from the command line
Add to `main()` before the loop:
```python
import sys
if len(sys.argv) > 1:
base = Path(sys.argv[1])
```
Then run as:
```bash
python thumbnail.py /path/to/images
```
---
## Output structure
```
Images/
WayBack/
IMG_0001.JPG ← original (can delete after upload)
thumbnails/
IMG_0001.jpg ← resized thumbnail → upload this
YourNomadSoul/
...
```
---
## After running
1. Commit the `thumbnails/` folders to git — these are small enough to live in the repo
2. Delete the originals from the local repo — do not commit large image files to git
3. Full-res originals stay on FileBrowser (already uploaded) — the gallery lightbox and download button pull from there