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

Delay with Animated GIFs not being applied? #153

Closed
lhl opened this Issue Sep 30, 2013 · 6 comments

Comments

6 participants
@lhl
Copy link

lhl commented Sep 30, 2013

I'm using v0.3.0 on OS X w/ (ImageMagick 6.8.6-0 2013-07-09 Q16 via MacPorts).

I am setting the delay property on the SingleImage's in the sequence (checking to make sure it is assigned), but when I save the file, it turns out that it doesn't include a delay at all? (verified w/ "identify -verbose out.gif | grep Delay")

Is there something simple I'm missing or something more I should test with or is this a bug?

@bywo

This comment has been minimized.

Copy link

bywo commented Nov 7, 2013

I'm having the same issue on Ubuntu with ImageMagick 6.8.7-5 Q16 x86_64 2013-11-07.

After setting a delay on all the SingleImages in sequence, I tried both Image.save and Image.make_blob. Both methods didn't apply the delay.

@bywo

This comment has been minimized.

Copy link

bywo commented Nov 7, 2013

@lhl after looking at the tests, I figured out how to set the frame delay correctly

# before
for frame in gif.sequence:
    frame.delay = 2

# after
for i in range(len(gif.sequence)):
    with gif.sequence[i] as frame:
        frame.delay = 2

the with clause calls SingleImage.destroy, which actually sets the image delay at the C API level.

@dahlia

This comment has been minimized.

Copy link
Collaborator

dahlia commented Nov 8, 2013

I think this code would also work:

for frame in gif.sequence:
    with frame:
        frame.delay = 2
@item4

This comment has been minimized.

Copy link
Contributor

item4 commented Nov 17, 2015

Hello, I'll add more test info for this issue.

See this.

>>> from wand.color import Color
>>> from wand.image import Image
>>> red = Color('red')
>>> blue = Color('blue')
>>> green = Color('green')
>>> ri = Image(width=100, height=100, background=red, format='GIF')
>>> bi = Image(width=100, height=100, background=blue, format='GIF')
>>> gi = Image(width=100, height=100, background=green, format='GIF')
>>> ri
<wand.image.Image: d02a8da '' (100x100)>
>>> bi
<wand.image.Image: 201aaeb '' (100x100)>
>>> gi
<wand.image.Image: 18ecdf4 '' (100x100)>
>>> rig = ri.convert('gif')
>>> rig
<wand.image.Image: d02a8da 'GIF' (100x100)>
>>> big = bi.convert('gif')
>>> gig = gi.convert('gif')
>>> container = Image(width=100, height=100)
>>> container.sequence
<wand.sequence.Sequence object at 0x10743be10>
>>> container.sequence.clear()
>>> container.sequence
<wand.sequence.Sequence object at 0x10743be10>
>>> container.sequence.append(rig)
>>> container.sequence[-1].delay = 1000
>>> container.sequence.append(big)
>>> container.sequence[-1].delay = 2000
>>> container.sequence.append(gig)
>>> container.sequence[-1].delay = 3000
>>> container.animation
True
>>> container.save('test.gif')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/item4/.virtualenvs/ugoira/lib/python3.5/site-packages/wand/image.py", line 2693, in save
    '.save(filename={0!r})?'.format(file))
TypeError: file must be a writable file object, but 'test.gif' is a string; did you want .save(filename='test.gif')?
>>> container.save(filename='test.gif')
>>>
>>> for frame in container.sequence:
...   print(frame.delay)
...
1000
2000
3000
>>> reopen = Image(filename='test.gif')
>>> for frame in reopen.sequence:
...   print(frame.delay)
...
0
0
0
>>> container.sequence.clear()
Exception ignored in: <bound method Resource.__del__ of <wand.sequence.SingleImage: 18ecdf4 (100x100)>>
Traceback (most recent call last):
  File "/Users/item4/.virtualenvs/ugoira/lib/python3.5/site-packages/wand/resource.py", line 232, in __del__
    self.destroy()
  File "/Users/item4/.virtualenvs/ugoira/lib/python3.5/site-packages/wand/sequence.py", line 334, in destroy
    with container.sequence.index_context(self.index):

>>> ontainer = Image(width=100, height=100)
>>> container.sequence.clear()
>>> container.sequence.append(rig)
>>> with container.sequence[-1]:
...   container.sequence[-1].delay = 1000
...
>>> container.sequence.append(big)
>>> with container.sequence[-1]:
...   container.sequence[-1].delay = 2000
...
>>> container.sequence.append(gig)
>>> with container.sequence[-1]:
...   container.sequence[-1].delay = 3000
...
>>> for frame in container.sequence:
...   print(frame.delay)
...
1000
2000
3000
>>> container.save(filename='test2.gif')
>>>
>>> reopen = Image(filename='test2.gif')
>>> for frame in reopen.sequence:
...   print(frame.delay)
...
1000
2000
3000
@robinpaulson

This comment has been minimized.

Copy link

robinpaulson commented Jan 27, 2017

Hi, I'm getting this problem with v0.3.9 on Ubuntu Xenial. Is it fixed in later versions?

@robinpaulson

This comment has been minimized.

Copy link

robinpaulson commented Jan 27, 2017

It appears wand installed via pip (v0.4.4) also has this bug. Any ETA on a fix?

Cheers

@emcconville emcconville added this to the 0.5.0 milestone Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment