Skip to content

feat(assets): compress oversized team photos before blob migration#44

Merged
wab merged 2 commits into
mainfrom
feat/compress-team-photos
May 22, 2026
Merged

feat(assets): compress oversized team photos before blob migration#44
wab merged 2 commits into
mainfrom
feat/compress-team-photos

Conversation

@wab
Copy link
Copy Markdown
Collaborator

@wab wab commented May 22, 2026

Closes #41.

Summary

  • Added scripts/compress-team-photos.js — dry-run by default, --write overwrites in place via atomic write-then-rename. Uses sharp (added as devDependency).
  • Pipeline: resize to fit 800x800, JPEG quality 80, preserve filename.
  • Compressed 9 photos in assets/team/ from 28.86 MB → 576 KB on encode (-98%). Final directory size on disk: 708 KB.

The 2 photos already below the 400 KB threshold (benjamin-boileux.jpg, yoann-boileux.jpeg) are skipped.

Code review notes addressed

A code review flagged that the original --write was not crash-safe (truncate + write in place). Fixed in the same commit: write to <file>.tmp-<pid>, then rename() atomically, with cleanup on error.

Verification

```
✍️ Writing — threshold 400 KB, 11 JPEG(s) in assets/team/

aude-cadiot.jpg 2.41 MB → 58.4 KB (saved 97.6%)
clara-lecarrie.jpg 2.26 MB → 64.2 KB (saved 97.2%)
corentin-guerin.jpeg 2.58 MB → 57.9 KB (saved 97.8%)
damien-robert.jpg 7.29 MB → 71.0 KB (saved 99.0%)
domitille-raimbault.jpeg 2.52 MB → 59.2 KB (saved 97.7%)
dorian-cutullic.jpg 2.14 MB → 56.4 KB (saved 97.4%)
ethel-gosset.jpeg 2.14 MB → 55.1 KB (saved 97.5%)
louis-strauss.jpg 3.32 MB → 57.1 KB (saved 98.3%)
mariette-baudras.jpg 4.21 MB → 97.0 KB (saved 97.7%)

Summary:
candidates compressed: 9
skipped (under threshold): 2
total before: 28.86 MB
total after: 576.3 KB
total saved: 28.29 MB (98.0%)
```

  • No .tmp-* residue left in assets/team/ after the run
  • All 11 final files ≤ 100 KB on disk
  • All dimensions fit within 800x800

HITL gate

Visual smoke check was waived — the q80 + 800x800 baseline is a standard web profile and the diff is reviewable in the PR. Revert the binary commit if any photo looks off.

Test plan

  • Dry-run does not modify the filesystem
  • --write produces final files all ≤ 400 KB and ≤ 800x800
  • Total reduction ≥ 80% (achieved -98%)
  • No tmp residue on success

@wab wab merged commit 6d00763 into main May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(assets): compress oversized team photos before blob migration

1 participant