Comments (5)
Discussion at #27 (comment)
from omggif.
Yeah, my claim is a lie. Sorry about that, misremembered the problem. Looks like I'll be ripping this mod out of the PR.
For the record, I was doing buffer management improperly. The proper technique is here: #27 (comment)
Also for the record, @deanm has superhuman patience for devs who are lost in the woods and don't know it.
from omggif.
@deanm, I think there is a problem writing with a global color table using the new buffer/position setter/getters.
I modified gifwrap
and ran my tests. I have tests for writing and reading both local and global color table versions of GIFs.
When I use your latest omggif.js
and provide a huge buffer, all of my tests run fine. But when I provide a buffer that has to scale in size, only the local color table tests work, even though they both run the same frame-writing and buffer-scaling code.
When trying to scale the buffer using a global color table, the encoding completes without error. However, when I try to read it back, I get GifError: Unknown gif block: 0x0
. Also, my Mac is unable to show it.
I don't have a stripped-down test of encoding/decoding to send you. I'm hoping you have a personal test for this. Mine is intimately tied to gifwrap
. However, you can see the algorithm here in my revision of a _writeFrame()
function that I use for writing all frames:
let buffer = gifWriter.getOutputBuffer();
let startOfFrame = gifWriter.getOutputBufferPosition();
let endOfFrame;
let tryAgain = true;
while (tryAgain) {
endOfFrame = gifWriter.addFrame(frame.xOffset, frame.yOffset,
frame.bitmap.width, frame.bitmap.height, frameInfo.buffer, options);
tryAgain = false;
if (endOfFrame >= buffer.length - 1) {
const biggerBuffer = new Buffer(buffer.length * 1.5);
buffer.copy(biggerBuffer);
gifWriter.setOutputBuffer(biggerBuffer);
gifWriter.setOutputBufferPosition(startOfFrame);
buffer = biggerBuffer;
tryAgain = true;
}
}
The two test cases that fail are this one and the next, which use this GIF and this GIF, respectively. Both of these GIFs are officially in the public domain.
I'm still keening for an omggif
test suite. ;-)
from omggif.
Okay, figured it out. The initial buffer has to be large enough for the header, including a global color table. My test started at a buffer size of 500 bytes to make sure everything was forced to scale, but that broke the global lookup table tests.
from omggif.
Okay, I posted a new version of gifwrap
that depends on an external omggif
. Thank you for so quickly taking care of all of this.
Also, I included tests for scaling the buffer size, which exercises both my code and yours.
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
- 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.