Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIF error for multiple duration values #4002

Closed
jiangying000 opened this issue Aug 1, 2019 · 0 comments · Fixed by #4003
Closed

GIF error for multiple duration values #4002

jiangying000 opened this issue Aug 1, 2019 · 0 comments · Fixed by #4003
Labels

Comments

@jiangying000
Copy link
Contributor

jiangying000 commented Aug 1, 2019

What did you do?

Using same images and a list of durations to produce a gif

What did you expect to happen?

produce the gif the specified durations

What actually happened?

failed when saving

What are your OS, Python and Pillow versions?

  • OS: win10
  • Python: 3.6
  • Pillow: 6.1.0

to reproduce, add following testcase to Tests/test_file_gif.py, then run pytest Tests/test_file_gif.py

    def test_totally_identical_frames(self):
        duration_list = [1000, 1500, 2000, 4000]

        out = self.tempfile("temp.gif")

        image_path = "Tests/images/bc7-argb-8bpp_MipMaps-1.png"
        im_list = [
            Image.open(image_path),
            Image.open(image_path),
            Image.open(image_path),
            Image.open(image_path),
        ]
        mask = Image.new("RGBA", im_list[0].size, (255, 255, 255, 0))

        frames = []
        for image in im_list:
            frames.append(Image.alpha_composite(mask, image))

        # duration as list
        frames[0].save(out,
                       save_all=True, append_images=frames[1:], optimize=False, duration=duration_list, loop=0,
                       transparency=0)

        reread = Image.open(out)

        # Assert that the first three frames were combined
        self.assertEqual(reread.n_frames, 1)

        # Assert that the new duration is the total of the identical frames
        self.assertEqual(reread.info["duration"], 8500)

err info is:

    if "duration" in im.encoderinfo:
        duration = int(im.encoderinfo["duration"] / 10)
        TypeError: unsupported operand type(s) for /: 'list' and 'int' 

bbox = None
im_frames.append({"im": im_frame, "bbox": bbox, "encoderinfo": encoderinfo})
if len(im_frames) > 1:
for frame_data in im_frames:

seems like we should copy duration info from im_frames[0] to im when len(im_frames) == 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants