matt-way / gifuct-js

Fastest javascript .GIF decoder/parser
MIT License
441 stars 63 forks source link

Artefacts while parsing #41

Closed ezioda004 closed 2 years ago

ezioda004 commented 3 years ago

Hi,

While parsing a couple of gifs, I found some artefacts are being created by the parser. What could be the reason for this? Example gif: https://giphy.com/gifs/croLDtGEfeuZMhtJI8 and https://giphy.com/stickers/transparent-nVpCrIoCfbLwinha2g

Artefact example:

https://user-images.githubusercontent.com/20020273/131472386-f330dc45-6389-4de1-a205-290ae8ec8fb5.mov

Please help me understand if this is something that can be fixed from the parser side?

I've also looked at other issues, one similar artefact issue fixed this by using this func:

const validateAndFix = (gif) => {
    let currentGce = null;
    for (const frame of gif.frames) {
        currentGce = frame.gce ? frame.gce : currentGce;

        // fix loosing graphic control extension for same frames
        if ("image" in frame && !("gce" in frame)) {
            frame.gce = currentGce;
        }
    }
};

but this didn't work with the mentioned gifs.

harm-less commented 2 years ago

It looks like you're not cleaning your draw area 🤔

In the demo your GIF example does work: http://matt-way.github.io/gifuct-js/

I just posted this code example that contains the correct cleaning after each frame, perhaps it helps you? https://stackoverflow.com/a/71664635/4341799