Skip to content

Converting animated webp images to animated gifs creates corrupt files #9311

@boosh

Description

@boosh

What did you do?

Tried to convert this animated webp to an animated gif.

Output file is corrupt and won't play in browsers (tried Firefox & Chrome).

What did you expect to happen?

Get a valid animated gif

What actually happened?

Got a corrupt gif.

Image

Image

animated.zip

What are your OS, Python and Pillow versions?

  • OS: Mac Sequoia 15.7.2
  • Python: 3.13.8
  • Pillow: 12.0.0
$ python3 -m PIL.report
--------------------------------------------------------------------
Pillow 12.0.0
Python 3.13.8 (main, Oct  7 2025, 12:01:51) [Clang 17.0.0 (clang-1700.0.13.3)]
--------------------------------------------------------------------
Python executable is ./venv/bin/python3
Environment Python files loaded from ./venv
System Python files loaded from /usr/local/opt/python@3.13/Frameworks/Python.framework/Versions/3.13
--------------------------------------------------------------------
Python Pillow modules loaded from ./venv/lib/python3.13/site-packages/PIL
Binary Pillow modules loaded from ./venv/lib/python3.13/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 12.0.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.14.1
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.6.0
--- AVIF support ok, loaded 1.3.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.2
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.4
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.2.5
--- LIBTIFF support ok, loaded 4.7.1
--- RAQM (Bidirectional Text) support ok, loaded 0.10.3, fribidi 1.0.16, harfbuzz 12.1.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
import os
import tempfile

from PIL import Image

img = Image.open(os.path.expanduser("~/Downloads/animated.webp"))

temp_file = tempfile.NamedTemporaryFile(suffix=".gif", delete=False)
temp_file_path = temp_file.name

img.save(
    temp_file_path,
    format="GIF",
    save_all=True,
    loop=0,
    optimize=False,
)
temp_file.close()
print(f"Converted webp file to gif at: {temp_file_path}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions