33 lines
528 B
Go
33 lines
528 B
Go
package utils
|
|
|
|
import (
|
|
"archive/zip"
|
|
"fmt"
|
|
"io"
|
|
"time"
|
|
|
|
"gitlab.com/gfxlabs/gfximg/apng"
|
|
)
|
|
|
|
func ZipApngs(w io.Writer, xs []*apng.APNG) error {
|
|
zw := zip.NewWriter(w)
|
|
defer zw.Close()
|
|
for i, v := range xs {
|
|
header := zip.FileHeader{
|
|
Name: fmt.Sprintf("./animations/a_%d.png", i),
|
|
NonUTF8: false,
|
|
Method: zip.Deflate,
|
|
Modified: time.Now(),
|
|
}
|
|
hw, err := zw.CreateHeader(&header)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = apng.Encode(hw, *v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|