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 {