Comments (9)
It took me a lot of struggle, but here is how Looping in GIFs work (or at least how browsers interpret it):
- to repeat forever, there should be the Netscape block containing 0
- to repeat just once, there should be no Netscape block
- to repeat N times (1<N), there should be a Netscape block containing N-1
Maybe you could make the "loop" input of GifWriter ("loop" output of GifReader) represent a true number of loops, and read/write it correspondingly? You could keep 0 as Forever.
from omggif.
Just to make sure I understand now, if you set loop
to undefined
on the GifWriter options, it behaves correctly and plays once? If you set loop
to 3 it loops 4 times?
from omggif.
I know it's a little inconvenient, but my intention with the library was to be as low level on top of the GIF format as possible, meaning it basically just handles writing out the format and doing the compression, but not much else, and gives the user fairly direct control over the output of the GIF file, etc. I think the first thing is just to document this clearly. Then I would still like loop
to mean "this is the value that gets written into the GIF file", but there could definitely be an additional helper function like gifLoopValueToActualPlayCount
(okay needs a better name) that will return the proper loop
value (including returning undefined/null for no block) for the actual number of times you want it to play, and the reverse calculation for reading.
from omggif.
Ok, I understand. But I just expected the "loop" property be the number of times the GIF repeats.
I could not find how this property works anywhere on the internet, so I discovered it by testing.
from omggif.
I think it's a manner of terminology. "loop" is the process of restarting to the beginning after hitting the end, so if something loops once it plays twice. So the play count is not the same as the loop count, the loop count is 1 less than the play count. Again if something "repeats" once it means in total it plays twice (the first one and then the 1 repeat). Does this make sense and match the behaviour you described?
from omggif.
Thats an interesting theory :D But loop=0 repeats forever .. should not it repeat just once? :D
from omggif.
Looping was added later (it's an extension block). Without any looping a gif will always play once, so the only question was how many additional times will it play. Therefore instead of adding some additional way of saying loop forever, they just made loop of 0 mean loop forever.
from omggif.
I understand, that they made it work in a certain way.
I am just saying, that your idea, that they intended to make the loop number correspond to the number of times skipping back, is very unprobable.
from omggif.
Don't know why you think it is unlikely, I am certain this is how it was designed.
I can't dig up the original Netscape references, but this is from the gifsicle code from the late 90s.
https://www.lcdf.org/gifsicle/man.html
--loopcount[=count]
Set the Netscape loop extension to count. Count is an integer, or forever to loop endlessly. If you supply a --loopcount option without specifying count, Gifsicle will use forever. --no-loopcount (the default) turns off looping.
Set the loop count to one less than the number of times you want the animation to run. An animation with --no-loopcount will show every frame once; --loopcount=1 will loop once, thus showing every frame twice; and so forth. Note that --loopcount=0 is equivalent to --loopcount=forever, not --no-loopcount.
"--loopcount=1 will loop once, thus showing every frame twice"
from omggif.
Related Issues (20)
- Implement streaming HOT 12
- Please add license file HOT 2
- Disposal method 2 not supported HOT 2
- Combine frames with transparency HOT 3
- Quantization and efficient frame encoding
- Are you accepting PRs? HOT 4
- Infinite loop on truncated GIF HOT 3
- Unhelpful exception on exceeding buffer bounds HOT 5
- Exceptions do not include a stack trace
- Enumerate public API? HOT 3
- Blending operations in GIFs HOT 2
- Upload to bower
- Get global palette from GIF HOT 6
- Invalid Block Size HOT 5
- Supporting corrupted GIFs to some degree HOT 2
- Attempt to use undefined value HOT 1
- MIT license? HOT 3
- Corrupted GIF at the output HOT 4
- frame ghosting and partial frames HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from omggif.