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/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 ``` 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 { /**