From f4ebb5cab170f986ee89a39c715b0328b18ced9b Mon Sep 17 00:00:00 2001 From: ycc Date: Sun, 27 Nov 2022 21:21:49 +0100 Subject: [PATCH] Write compressed ContactCard --- contactcard.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contactcard.go b/contactcard.go index d842f3d..129bf72 100644 --- a/contactcard.go +++ b/contactcard.go @@ -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 {