From 763840a2b84e1998ba5ef033f627d025aeec38e2 Mon Sep 17 00:00:00 2001 From: Eirini Galati Date: Wed, 4 Nov 2026 13:42:52 +0100 Subject: [PATCH] docs: use the Format constants in the README convert examples The convert examples passed raw media-type strings, so nothing in the README pointed at the constants this release adds. They now use tinify.Format, with a note that the plain strings still work, and the feature list mentions JPEG XL alongside the other convert targets. --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eeb99c9..a090b2e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # Tinify API client for Python -**Tinify** is the official Python client for the [TinyPNG](https://tinypng.com) and [TinyJPG](https://tinyjpg.com/) image compression API, enabling developers to intelligently compress, resize, convert and optimize PNG, APNG, JPEG, WebP and AVIF images programmatically. Read more at [https://tinify.com](https://tinify.com/developers). +**Tinify** is the official Python client for the [TinyPNG](https://tinypng.com) and [TinyJPG](https://tinyjpg.com/) image compression API, enabling developers to intelligently compress, resize, convert and optimize PNG, APNG, JPEG, WebP, AVIF and JPEG XL images programmatically. Read more at [https://tinify.com](https://tinify.com/developers). [Go to the full documentation for the Python client](https://tinypng.com/developers/reference/python). @@ -16,7 +16,7 @@ - Compress and optimize images, reducing file size by 50-80% while preserving visual quality - Resize and crop images with smart compression -- Convert between PNG, JPEG, WebP and AVIF formats +- Convert between PNG, JPEG, WebP, AVIF and JPEG XL formats - Preserve metadata (optional) - Upload to storage providers like Amazon S3, Google cloud storage. - Apply visual transformations with the Tinify API @@ -89,19 +89,22 @@ tinify.from_file("original.jpg").resize( ```python # Convert to WebP format tinify.from_file("image.png").convert( - type=["image/webp"] + type=tinify.Format.WEBP ).to_file("image.webp") ``` ```python # Convert to smallest format +# (tinify.Format.WEBP, PNG, JPEG, JPG, AVIF, JXL and ANY) converted = tinify.from_file("image.png").convert( - type=["image/webp", "image/avif", "image/jxl"] + type=[tinify.Format.WEBP, tinify.Format.AVIF, tinify.Format.JXL] ) extension = converted.result().extension converted.to_file("image." + extension) ``` +The constants are plain strings, so `type="image/webp"` keeps working. + ### Compression Count Monitoring ```python