internal/thumb/README.md
Last Updated: March 6, 2026
internal/thumb builds thumbnails with libvips, handling resize/crop options, color management, metadata stripping, and format export (JPEG/PNG). It is used by PhotoPrism’s workers and CLI to generate cached thumbs consistently.
VipsInit.github.com/davidbyttow/govips/v2).fs.ModeFile.InteroperabilityIndex (R03/Adobe RGB, R98/sRGB, THM/thumbnail), we embed an Adobe-compatible profile; otherwise we leave color untouched.vips.go — main Vips entry: load, resize/crop, strip metadata, export.vips_icc.go — EXIF InteroperabilityIndex handling and ICC embedding.icc.go — lists bundled ICC filenames (IccProfiles) and GetIccProfile helper.resample.go, sizes.go — resample options and predefined sizes.thumb.go and helpers — naming, caching, file info.*_test.go, fixtures under testdata/).InteroperabilityIndex codes we honor (per EXIF TagNames and regex.info):
R03 → Adobe RGB (1998) compatible (a98.icc, etc.)R98 → sRGB (assumed default; no embed)THM → Thumbnail (treated as sRGB; no embed)exif-ifd4-InteroperabilityIndex):
exiftool -InteropIndex -InteropVersion -icc_profile:all -G -s file.jpg
testdata/interop_index.jpg — R03 interop tag, no ICC (expects Adobe profile embed).testdata/interop_index_srgb_icc.jpg — R03 tag with embedded ICC (must remain unchanged).testdata/interop_index_r98.jpg — R98 interop tag, no ICC (should stay sRGB without embedding).testdata/interop_index_thm.jpg — THM interop tag, no ICC (thumbnail; should remain unchanged).go test ./internal/thumb -run 'Icc|Vips' -count=1go test ./internal/thumb -count=1make fmt-gomake lint-go or golangci-lint run ./internal/thumb/...assets/profiles/icc/ and append to IccProfiles.Go 1.26.0 replaced the standard image/jpeg encoder and decoder. This package primarily relies on libvips for thumbnail generation, but helper paths and tests that decode or encode JPEGs through Go libraries can observe behavior changes after toolchain upgrades.
Observed impact during internal comparison runs (Go 1.25.4 vs 1.26.0):
assets/samples on either version.+0.014% at default quality, about +0.017% at quality 95 in our fixture scan).1.26.0.Testing guidance: