Detect a fetched image's format from its bytes once (closes #319)
check / check (push) Canceled after 0s

magic.DetectFormat returns an imagerequest.Format. ValidateMagicBytes
returns the format it checked against the upstream Content-Type. The
cache stores that format in the source's row, so a variant made from a
cached source uses it too. The proxy hands it to Process, which still
refuses input libvips would load with another loader, such as an SVG
passing as AVIF. Format.MIMEType declares each MIME string once, and the
fetcher, the cache's variant read and the Accept matching use it.
magic.MIMEType, magic.ImageFormat, MIMEToImageFormat, magic's SVG
detection, detectFormat, formatFromString, FormatToMIME and
Result.InputFormat are gone.

Model: opus-5-5
This commit is contained in:
2026-10-26 19:46:01 +00:00
parent ac850823f4
commit adfb6ab50a
39 changed files with 430 additions and 594 deletions
+5 -4
View File
@@ -191,10 +191,11 @@ allowlisted source hosts for open access.
name.
Each source image and each transformed image has one row in the database,
holding its size and when it was last used. Two source URLs that serve the same
bytes are stored twice, once under each URL. A source image is stored by writing
its file and then its row; when the row cannot be written, the file is removed
again.
holding its size and when it was last used. A source image's row also holds its
format, which pixa reads from the image's first bytes when it fetches it. Two
source URLs that serve the same bytes are stored twice, once under each URL. A
source image is stored by writing its file and then its row; when the row cannot
be written, the file is removed again.
Source and transformed image files are written under a temporary name, synced to
disk, and only then renamed into place, so a crash leaves no file under its own