Git Product home page Git Product logo

Comments (2)

deanm avatar deanm commented on July 22, 2024

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.

leeoniya avatar leeoniya commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.