Skip to content

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

Merged
Sreini merged 2 commits into
masterfrom
feat/jxl-format
Nov 4, 2026
Merged

Sreini merged 2 commits into
masterfrom
feat/jxl-format

Conversation

@Sreini

@Sreini Sreini commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

@Sreini
Sreini force-pushed the feat/jxl-format branch 2 times, most recently from 6e308bc to fecbff3 Compare November 4, 2026 09:49
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.

JPG documents image/jpg as the alternative spelling the API also
accepts. It normalises to image/jpeg before conversion, so the two
constants hold different strings but select the same format.

Bumps to 1.9.0, promotes the changelog entry out of Unreleased, and
updates Gemfile.lock to match -- bundler runs frozen in CI and exits 16
when the lockfile still pins the previous version. The change is
additive, so this is a minor release; nothing is published until the
matching tag is pushed.
The README only showed compression, so the constants this release adds
had no example outside the API docs site. Adds a convert example using
Tinify::Format, the multiple-types case, and a note that the plain
strings still work.
@Sreini
Sreini merged commit acaab5d into master Nov 4, 2026
50 checks passed
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