Write compressed ContactCard

This commit is contained in:
ycc 2022-11-27 21:21:49 +01:00
parent 8195a22300
commit f4ebb5cab1

View File

@ -7,6 +7,7 @@ import (
"image"
"image/color"
"image/png"
"io/ioutil"
"log"
"math"
"os"
@ -53,6 +54,18 @@ func (contact *ContactCard) Compress() ([]byte, error) {
return b.Bytes(), nil
}
func (contact *ContactCard) WriteCompressed(filename string) error {
out, err := contact.Compress()
if err != nil {
return err
}
err = ioutil.WriteFile(filename, out, 0600)
if err != nil {
return err
}
return nil
}
func (contact *ContactCard) WritePng(filename string) {
out, err := proto.Marshal(contact)
if err != nil {