30 lines
599 B
Go
30 lines
599 B
Go
package main
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"strings"
|
|
)
|
|
|
|
// A naiive subset of what's in a .pixil file
|
|
type PixilFrame struct {
|
|
Active bool `json:"active"`
|
|
Preview string `json:"preview"`
|
|
}
|
|
type Pixil struct {
|
|
Width uint `json:"width"`
|
|
Height uint `json:"height"`
|
|
Frames []PixilFrame `json:"frames"`
|
|
}
|
|
|
|
func (frame *PixilFrame) GetPreview() []byte {
|
|
if !frame.Active {
|
|
return nil
|
|
}
|
|
if !strings.HasPrefix(frame.Preview, "data:image/png") {
|
|
return nil
|
|
}
|
|
png := strings.Split(frame.Preview, ",")[1]
|
|
preview, _ := base64.StdEncoding.DecodeString(png)
|
|
return preview
|
|
}
|