From 2077d4290f3041c4d48f27b82c1db98443b7bb53 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 5 Aug 2026 10:43:28 +0100 Subject: [PATCH] map jpg -> jpeg, and support other mapping in future --- resources/worker/src/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/worker/src/index.js b/resources/worker/src/index.js index 2445ef4..60df7b7 100644 --- a/resources/worker/src/index.js +++ b/resources/worker/src/index.js @@ -9,6 +9,14 @@ const FIT_MAP = { stretch: 'squeeze', }; +// Glide-style `fm` values -> Workers Images binding output format subtypes. +// Glide/browsers use `jpg`, but the Images binding only accepts the +// `image/jpeg` MIME type — passing `image/jpg` fails with +// IMAGES_TRANSFORM_ERROR 9432 (invalid output format). +const FORMAT_MAP = { + jpg: 'jpeg', +}; + // The client only ever sees a bare 404 — distinct reasons (bad signature, // unknown disk, malformed modifiers, missing source file) are logged // server-side instead, so a prober can't use the response to tell which @@ -119,7 +127,7 @@ export default { // the whole chain up to and including .output() must be awaited // first, or .response() is called on the still-pending Promise. const output = await transformed.output({ - format: options.fm ? `image/${options.fm}` : 'image/webp', + format: options.fm ? `image/${FORMAT_MAP[options.fm] ?? options.fm}` : 'image/webp', quality: options.q, });