-
-
Notifications
You must be signed in to change notification settings - Fork 705
fix: make gif-loop consistent between GIF and WEBP #1362
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
Conversation
Hello @deftomat, I hadn't realized that GIF loop == 1 actually meant play twice (ie. rewind once). I think the So how about:
For reference, giflib: 0 == forever, 1 == play twice, 2 == play 3 times, etc. IM uses the same convention as webp. What do you think? |
Handy for testing: #!/usr/bin/python3
import sys
import pyvips
im = pyvips.Image.new_from_file(sys.argv[1], n=-1, access="sequential")
im = im.copy()
im.set("gif-loop", int(sys.argv[3]))
im.write_to_file(sys.argv[2]) Then:
|
Hi. Yes, it sounds good. I will update it. |
@jcupitt I'm not exactly sure how we want to deprecate |
ping @jcupitt π |
Hiya, sorry for not responding. I think the savers should all do this:
libvips has a deprecation system for header fields, so we can add "gif-loop" to that and it'll vanish from all interfaces, though it'll still work if you use it explicitly. |
@jcupitt I add Also, I add |
OK, let's merge. I can see a couple of tiny things, but I'll zap them in another patch. Thank you very much for working on this, @deftomat ! |
I added some other file types to .editorconfig, adjusted some formatting, and added "gif-loop" to the list of deprecated (and hidden) metadata fields. |
AWESOME, thanks π Is there an automated way how to format files in this project? Because I always forgot to put spaces into IFs π |
I keep meaning to write an indent file, but I'm too lazy :( |
We discovered that converting GIF into WEBP can unexpectedly change number of iterations.
The problem is that
gif-loop=2
in GIF means 3 iterations and just 2 iterations in WEBP.So, this PR is trying to unify gif-loop for both formats.
Now, the default GIF value is 1 iteration and when
gifload
found netscape extension block, then it will change it to 0 (infinite loop) or to the real number of iterations. So, for example, when we found 2, we store it as 3 as viewer should iterate 3 times until it stops.Now, it is possible to load GIF and immediately save it into WEBP without worrying that the number of iterations will reduce by 1.
I think that this change can be a breaking change for GIF but unfortunately, it is also a bug for WEBP.
Maybe, we should use different name, for example:
loop
closes #1502