Comments (2)
Making the color map be the same for all frames is quite easy. In GIFEncoder.js, you can do:
// with variable declarations (line 61)
var nq = null;
exports.reuseColorTable = false;
// in analyzePixels (line 335)
indexedPixels = [];
if (!nq) {
nq = new NeuQuant(pixels, len, sample); // initialize quantizer
colorTab = nq.process(); // create reduced palette
}
// map image pixels to new or existing palette
var k = 0;
for (var j = 0; j < nPix; j++) {
var index = nq.map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff);
usedEntry[index] = true;
indexedPixels[j] = index;
}
if (!exports.reuseColorTable) {
nq = null;
}
pixels = null;
This is what I'm doing in the application I'm writing. The only downside is that the global color map is based off of the first frame, so if the first frame is not representative of the colors in the rest of the frames, the colors in those frames will be wonky. Other than that it is quite nice because reusing the color map speeds up encoding by about 40%, and static objects no longer have the weird "glimmer" throughout the GIF from the colors changing slightly from frame-to-frame.
from jsgif.
@joswhite Thanks for your reply! Just like your said, based off the first frame will behaves incorrectly in some cases. It can be an option, but may not be the default behavior.
from jsgif.
Related Issues (20)
- No license information HOT 1
- `addFrame` with `is_imageData=true` makes Chrome hang up HOT 3
- Writing canvas to GIF outputs double speed GIF HOT 1
- License HOT 1
- last frame of addFrame is not added to gif HOT 1
- Data URI generates a black gif HOT 4
- jsapng? can you make convas into animated PNG? HOT 5
- GIF almost empty HOT 4
- Animated Gif comes out black w/ Web Workers HOT 6
- Pixel width black line on left edge of GIF
- Add git tag
- My webcam snapshot is being overlay by the gif ??
- No plugin.xml file
- Color Reproduction Issue HOT 2
- Fixes report HOT 1
- Crashes at 300+ Frames HOT 2
- License? HOT 2
- The encoding of the Gif fails depending on the size of the canvas HOT 1
- Background image shown in canvas but not in image output HOT 7
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 jsgif.