feat: add Format constants for convert media types, including JXL - #50
feat: add Format constants for convert media types, including JXL#50Sreini wants to merge 1 commit into
Conversation
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.
|
The phpstan failure here is pre-existing on It reports 2 errors in Verified by pushing a throwaway branch at Cause: Worth fixing separately — either pin phpstan, commit a |
|
Follow-up: the macOS unit-test failures are also pre-existing, not caused by this PR. They are cancelled, not failed — killed inside Cause: Verified against a throwaway branch at
Same for 5.6, 7.4 and 8.0. So this PR has two independent pre-existing CI issues stacked on it — unpinned phpstan (see previous comment) and the macOS |
Adds a
Formatnamespace of media-type constants so the types accepted byconvertare discoverable via autocomplete — including JPEG XL(
image/jxl), which the API already accepts but no client surfaced.image/jxlis already in the API allowlist (apps/api/src/schemas/optimizations.tsand
apps/opt-api/src/constants/content-types.ts), so this is a client-sidediscoverability change only. There is no API-side work outstanding.
Members
WEBP,PNG,JPEG,JPG,AVIF,JXL,ANY(*/*) — mirroring theAPI 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 keepthis fully backward compatible: callers passing raw strings are unaffected.
Verification
php -lnor PHPUnit could be run. The three newTinifyFormatTestcases and the syntax oflib/Tinify/Format.phprely on CI. Please confirm CI is green before merging.Note
composer.jsonrequires PHP>=5.3.0, hence class constants rather than anenum(8.1+).Part of a coordinated change across all six Tinify client libraries, so the
same
FormatAPI is available in each.