LinusU / cwasm-nsgif

GIF decoding for Node.js, using Libnsgif compiled to WebAssembly
40 stars 0 forks source link

Support animated GIF #1

Open sindresorhus opened 4 years ago

sindresorhus commented 4 years ago

Would be nice if this package supported decoding animated GIFs.

LinusU commented 4 years ago

Sounds good!

Any suggestions on how the API should look?

sindresorhus commented 4 years ago
const image = nsgif.decodeAnimation(source)

console.log(image)
/*
{
    width: 128,
    height: 128,
    frames: [
        {
            timeCode: 0.1,
            data: Uint8ClampedArray [ ... ]
        }
    ]
}
*/
LinusU commented 4 years ago

Hmmm, that might be a bit too high level for this library. From your suggestion I assume that you want the frames processed so that each object in frames contains a complete image that can be rendered/shown directly.

I think that I want to split out that part as a separate library, and let this library only deal with giving you what's in the file/what nsgif gives me.

I'm almost done with the decoding part but need to take a break for something else, hopefully I'll get this done tonight 👍


Actually, it seems like nsgif handles merging frames and will always have a complete image in the frame buffer after calling gif_decode_frame so I think it would be appropriate to give each complete frame in an array after all ☺️