MCPcopy Create free account
hub / github.com/fogleman/primitive / SaveGIFImageMagick

Function SaveGIFImageMagick

primitive/util.go:87–109  ·  view source on GitHub ↗
(path string, frames []image.Image, delay, lastDelay int)

Source from the content-addressed store, hash-verified

85}
86
87func SaveGIFImageMagick(path string, frames []image.Image, delay, lastDelay int) error {
88 dir, err := ioutil.TempDir("", "")
89 if err != nil {
90 return err
91 }
92 for i, im := range frames {
93 path := filepath.Join(dir, fmt.Sprintf("%06d.png", i))
94 SavePNG(path, im)
95 }
96 args := []string{
97 "-loop", "0",
98 "-delay", fmt.Sprint(delay),
99 filepath.Join(dir, "*.png"),
100 "-delay", fmt.Sprint(lastDelay - delay),
101 filepath.Join(dir, fmt.Sprintf("%06d.png", len(frames)-1)),
102 path,
103 }
104 cmd := exec.Command("convert", args...)
105 if err := cmd.Run(); err != nil {
106 return err
107 }
108 return os.RemoveAll(dir)
109}
110
111func NumberString(x float64) string {
112 suffixes := []string{"", "k", "M", "G"}

Callers

nothing calls this directly

Calls 1

SavePNGFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…