From 6df6bff174087134d8c894dab644edf1e7da77b9 Mon Sep 17 00:00:00 2001 From: Eirini Galati Date: Wed, 4 Nov 2026 10:46:00 +0100 Subject: [PATCH 1/2] chore: release 1.7.0 Promotes the Format constants entry out of Unreleased and bumps VERSION. The change is additive -- new constants, no signature or behaviour change -- so this is a minor release. Note that unlike the other client libraries, this repo has no publish job: Packagist derives the released version from the git tag, and nothing verifies that VERSION in lib/Tinify.php matches that tag. The constant only feeds the User-Agent, so a mismatch would not break callers, but it would misreport the client version to the API indefinitely. Keep the two in step when tagging. --- CHANGES.md | 2 +- lib/Tinify.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2d344a7..d5ec5f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -## Unreleased +## 1.7.0 * Added `Format` constants for the media types `convert` accepts, including JPEG XL (`image/jxl`). diff --git a/lib/Tinify.php b/lib/Tinify.php index cce7f68..db2aea0 100644 --- a/lib/Tinify.php +++ b/lib/Tinify.php @@ -2,7 +2,7 @@ namespace Tinify; -const VERSION = "1.6.4"; +const VERSION = "1.7.0"; class Tinify { /** From b585f21ba0c921e2109251e4694d418e08f36270 Mon Sep 17 00:00:00 2001 From: Eirini Galati Date: Wed, 4 Nov 2026 14:53:03 +0100 Subject: [PATCH 2/2] docs: document the Format constants in the README The README only showed compression, so the constants added in 1.7.0 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. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 59d5030..26c675b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,28 @@ Tinify\setKey("YOUR_API_KEY"); Tinify\fromFile("unoptimized.png")->toFile("optimized.png"); ``` +Convert to another format with the `Tinify\Format` constants (`WEBP`, `PNG`, +`JPEG`, `JPG`, `AVIF`, `JXL` and `ANY`): + +```php +Tinify\fromFile("unoptimized.png") + ->convert(array("type" => Tinify\Format::JXL)) + ->toFile("optimized.jxl"); +``` + +Pass several and the API returns the smallest result: + +```php +$converted = Tinify\fromFile("unoptimized.png") + ->convert(array("type" => array(Tinify\Format::JXL, Tinify\Format::WEBP))); + +$result = $converted->result(); +echo $result->mediaType(); // the format the API picked +$result->toFile("optimized"); +``` + +The constants are plain strings, so `"type" => "image/jxl"` keeps working. + ## Running tests ```