Skip to content

Instantly share code, notes, and snippets.

@betandr
Created September 9, 2018 08:40
Show Gist options
  • Save betandr/45e03c147dcb8b4f263b024fa815bc9c to your computer and use it in GitHub Desktop.
Save betandr/45e03c147dcb8b4f263b024fa815bc9c to your computer and use it in GitHub Desktop.
Very Basic Gif Maker
package main
import "image"
import "image/gif"
import "os"
func main() {
files := os.Args[1:]
// files := []string{"g1.gif", "g2.gif","g3.gif", "g2.gif"}
// load static image and construct outGif
outGif := &gif.GIF{}
for _, name := range files {
f, _ := os.Open(name)
inGif, _ := gif.Decode(f)
f.Close()
outGif.Image = append(outGif.Image, inGif.(*image.Paletted))
outGif.Delay = append(outGif.Delay, 0)
}
// save to out.gif
// f, _ := os.OpenFile("out.gif", os.O_WRONLY|os.O_CREATE, 0600)
// defer f.Close()
gif.EncodeAll(os.Stdout, outGif)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment