Skip to content

feat: add Format constants for convert media types, including JXL - #19

Open
Sreini wants to merge 1 commit into
masterfrom
feat/jxl-format
Open

feat: add Format constants for convert media types, including JXL#19
Sreini wants to merge 1 commit into
masterfrom
feat/jxl-format

Conversation

@Sreini

@Sreini Sreini commented Sep 3, 2026

Copy link
Copy Markdown

Adds a Format namespace of media-type constants so the types accepted by
convert are discoverable via autocomplete — including JPEG XL
(image/jxl), which the API already accepts but no client surfaced.

image/jxl is already in the API allowlist (apps/api/src/schemas/optimizations.ts
and apps/opt-api/src/constants/content-types.ts), so this is a client-side
discoverability change only. There is no API-side work outstanding.

Members

WEBP, PNG, JPEG, JPG, AVIF, JXL, ANY (*/*) — mirroring the
API allowlist exactly.

Why string constants and not an enum

The JSON body has to carry the media type verbatim. A language-level enum
serializes as its name or ordinal, not image/jxl. String constants also keep
this fully backward compatible: callers passing raw strings are unaffected.

Verification

Syntax verified (ruby -c on both changed files). The test suite could not be run locally — the repo targets Ruby 4.0.1 (.ruby-version) and only system Ruby 2.6.10 is available here with no version manager, so bundle fails on a bundler version mismatch. The two new tinify_format_test.rb cases rely on CI. Please confirm CI is green before merging.

Part of a coordinated change across all six Tinify client libraries, so the
same Format API is available in each.

Adds a Format namespace of media-type string constants so the types
accepted by convert() are discoverable via autocomplete, including
JPEG XL (image/jxl), which the API already accepts.

String constants rather than a language-level enum: the JSON body must
carry the media type verbatim, and an enum would serialize as its name.
Existing callers passing raw strings are unaffected.
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.

1 participant