Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Unreleased
## 1.7.0

* Added `Format` constants for the media types `convert` accepts, including JPEG XL (`image/jxl`).

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
2 changes: 1 addition & 1 deletion lib/Tinify.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tinify;

const VERSION = "1.6.4";
const VERSION = "1.7.0";

class Tinify {
/**
Expand Down
Loading