Skip to content

Commit

Permalink
Update documentation for AVIF support
Browse files Browse the repository at this point in the history
  • Loading branch information
salty-ivy authored and zerolab committed Jul 10, 2023
1 parent 0177eef commit e076c34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 12 additions & 2 deletions docs/guide/save.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ In Willow there are separate save operations for each image format:
- :meth:`~Image.save_as_png`
- :meth:`~Image.save_as_gif`
- :meth:`~Image.save_as_webp`
- :meth:`~Image.save_as_svg`
- :meth:`~Image.save_as_heic`
- :meth:`~Image.save_as_avif`


All three take one positional argument, the file-like object to write the image
data to.
Expand Down Expand Up @@ -46,14 +50,20 @@ can force Willow to always save a "progressive" JPEG file by setting the
with open('progressive.jpg', 'wb') as f:
i.save_as_jpeg(f, progressive=True)
Lossless WebP
Lossless AVIF, HEIC and WebP
-----------------

You can encode the image to WebP without any loss by setting the
You can encode the image to AVIF, HEIC (Pillow-only) and WebP without any loss by setting the
``lossless`` keyword argument to ``True``:

.. code-block:: python
with open('lossless.avif', 'wb') as f:
i.save_as_avif(f, lossless=True)
with open('lossless.heic', 'wb') as f:
i.save_as_heic(f, lossless=True)
with open('lossless.webp', 'wb') as f:
i.save_as_webp(f, lossless=True)
Expand Down
15 changes: 15 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ Here's a full list of operations provided by Willow out of the box:
image.save_as_heic(f)
.. method:: save_as_avif(file, quality=80, lossless=False)

(requires the pillow-heif library)

Saves the image to the specified file-like object in AVIF format.
When saving with `lossless=True`, the `quality` value is set to `-1` and `chroma` to `444`.

returns a ``AvifImageFile`` wrapping the file.

.. code-block:: python
with open('out.avif', 'wb') as f:
image.save_as_avif(f)
.. method:: save_as_svg(file)

(SVG images only)
Expand Down

0 comments on commit e076c34

Please sign in to comment.