python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.31k stars 2.23k forks source link

GIF only shows the first image, not the others #8119

Closed Jasonlee1995 closed 5 months ago

Jasonlee1995 commented 5 months ago

What did you do?

I was going to generate gif file using images, but generated gif file behaves as static image.

What did you expect to happen?

generated gif with images moving dynamically(?)

What actually happened?

only the first image is shown, not the other images (same as png file)

What are your OS, Python and Pillow versions?

python3 -m PIL --report

--------------------------------------------------------------------
Pillow 10.3.0
Python 3.9.13 (main, Oct 13 2022, 16:12:19)
       [Clang 12.0.0 ]
--------------------------------------------------------------------
Python executable is /Users/jason/opt/miniconda3/envs/py39/bin/python3
System Python files loaded from /Users/jason/opt/miniconda3/envs/py39
--------------------------------------------------------------------
Python Pillow modules loaded from /Users/jason/opt/miniconda3/envs/py39/lib/python3.9/site-packages/PIL
Binary Pillow modules loaded from /Users/jason/opt/miniconda3/envs/py39/lib/python3.9/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.3.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.3.2
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.2
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.6.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------

from PIL import Image

test_imgs = ['./test_img0.png', './test_img1.png']
test_pil_imgs = [Image.open(test_img) for test_img in test_imgs]

test_pil_imgs[0].save(
    './test.gif', 
    append_imgs=test_pil_imgs[1:], 
    save_all=True, 
    optimize=False, 
    duration=500, 
    loop=0
)
image

I expect the gif moves sequentially. (dynamic such as test_img0 -> test_img1 -> test_img0 -> test_img1)

But the resulting gif file do not make any moves. (static - only the front image test_img0 is shown)

radarhere commented 5 months ago

Hi. In your code, you have written append_imgs. It is actually append_images

Jasonlee1995 commented 5 months ago

Oh my... sorry for stupid question :(