Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion resources/worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
});

Expand Down
Loading