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

Pass repeat count by argument #4

Closed
borisdering opened this issue Apr 5, 2018 · 5 comments
Closed

Pass repeat count by argument #4

borisdering opened this issue Apr 5, 2018 · 5 comments

Comments

@borisdering
Copy link

Is it possible to pass a repeat count to the apng file? At the moment the repeat count stands at "-1" for repeat forever? Does the specification for apng even support repeat count?

@eight04
Copy link
Owner

eight04 commented Apr 5, 2018

Yes, you can specify repeat count in APNG. In this library, the repeat count is always 0 (infinite):

out.append(make_chunk("acTL", struct.pack("!II", len(self.frames), 0)))

And it is ignored when reading frames from an APNG file:

pyAPNG/apng/__init__.py

Lines 347 to 348 in aeb6973

elif type == "acTL":
continue

I think we should expose it as a public property num_plays of APNG instance.

@borisdering
Copy link
Author

Wow! thank you for the very fast reply. The way to pass this argument would be amazing and would solve my issue. Anyways, how should we move on? I'm pretty new to python and especially to APNG. Should I make the changes or would you like to go ahead?

@eight04
Copy link
Owner

eight04 commented Apr 5, 2018

PRs welcome. I would expect something like:

im = APNG.from_files(some_files)
assert im.num_plays == 0
im.num_plays = 5
im.save(result_file) # the result animation should only repeat 5 times

im = APNG.open(result_file)
assert im.num_plays == 5

@ghost
Copy link

ghost commented Mar 5, 2019

pyAPNG works great, and I do like it a lot.

Regarding #4, could you add a code example to the documtation, how an infinite repeat as well as only-play-once of the animation should be written? Thanks in advance!

@eight04
Copy link
Owner

eight04 commented Mar 5, 2019

APNG object has a num_plays property. You can modify this property before writing APNG to file.

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

No branches or pull requests

2 participants