Comments (2)
Hi Leon,
In theory this is something that is possible, but currently not supported. The reason it works like it does, is that omggif writes the GIF file linearly, from the beginning to the end. The global palette is stored in the GIF file before the frames. If you wanted to set the palette later, you would have to put in a placeholder and then later go back and update the palette. This is not so difficult if you know in advance the size that the palette will be.
I don't see this as a particularly important feature to add to omggif itself, but if you wanted to make your own modification it shouldn't be difficult. Take a look at line 78 where it writes out the global palette. Here you could have passed in a placeholder palette, and store the current index of the output buffer (the variable p here). Later you could go back and write in the palette.
If you want to be a bit sneaky here is an alternative that might work. The GifWriter constructor takes a buffer, and it will overwrite the contents of whatever is in that buffer, but it does nothing to clear it in advance. So, if you write the gif once with a placeholder palette, you could make a second pass where you create a GifWriter with that same buffer and same arguments, basically overwriting the header, but this time with the right palette. Make sure not to call end() obviously the second time around. I didn't think about it too hard but I reckon that might work for you.
from omggif.
Thanks for the tips, I'll look into these options when it becomes an issue; for now it'd be premature optimization. omggif is working great for me otherwise. If you have any advice on estimating an appropriate buffer size in advance, I'd like to hear it. I feel like LZW & frame complexity really make this near impossible :(
cheers!
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
- Loop count when exporting GIF HOT 9
- 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.