summaryrefslogtreecommitdiffstats
path: root/bridge/helper/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/helper/helper.go')
-rw-r--r--bridge/helper/helper.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go
index 3836556f..c336fd13 100644
--- a/bridge/helper/helper.go
+++ b/bridge/helper/helper.go
@@ -3,6 +3,7 @@ package helper
import (
"bytes"
"fmt"
+ "image/png"
"io"
"net/http"
"regexp"
@@ -10,6 +11,8 @@ import (
"time"
"unicode/utf8"
+ "golang.org/x/image/webp"
+
"github.com/42wim/matterbridge/bridge/config"
"github.com/sirupsen/logrus"
"gitlab.com/golang-commonmark/markdown"
@@ -177,3 +180,19 @@ func ParseMarkdown(input string) string {
md := markdown.New(markdown.XHTMLOutput(true), markdown.Breaks(true))
return (md.RenderToString([]byte(input)))
}
+
+// ConvertWebPToPNG convert input data (which should be WebP format to PNG format)
+func ConvertWebPToPNG(data *[]byte) error {
+ r := bytes.NewReader(*data)
+ m, err := webp.Decode(r)
+ if err != nil {
+ return err
+ }
+ var output []byte
+ w := bytes.NewBuffer(output)
+ if err := png.Encode(w, m); err != nil {
+ return err
+ }
+ *data = w.Bytes()
+ return nil
+}