Skip to content

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

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

Sreini wants to merge 1 commit 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

Full suite green locally: dotnet test -f net9.0 → 86 passed, 2 pre-existing skips, including 3 new FormatTest cases.

Note: the net8.0 target could not run locally (that runtime isn't installed on this machine) — CI covers it.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is additive and low-risk with test coverage, with only a minor documentation wording mismatch noted.

Pull request overview

Adds a TinifyAPI.Format static class of string media-type constants to make Source.Convert’s accepted type values discoverable via autocomplete (including JPEG XL / image/jxl), with accompanying unit tests and a changelog entry.

Changes:

  • Introduced TinifyAPI.Format constants for supported convert media types (image/webp, image/png, image/jpeg, image/jpg, image/avif, image/jxl, */*).
  • Added NUnit tests asserting the constants and verifying Convert serializes Format values correctly (single and multiple types).
  • Documented the addition in CHANGES.md under “Unreleased”.
File summaries
File Description
test/Tinify.Tests/FormatTest.cs Adds unit tests for Format constants and Convert request serialization using them.
src/Tinify/Format.cs Introduces the Format constants API (including image/jxl) with XML documentation.
CHANGES.md Notes the new Format constants in the unreleased changelog.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Tinify/Format.cs
/// <summary>JPEG, <c>image/jpeg</c>.</summary>
public const string Jpeg = "image/jpeg";

/// <summary>JPEG, <c>image/jpg</c>. An alias of <see cref="Jpeg"/>.</summary>
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.

2 participants