Browse Source

fix image media webp to png convertion logic

pull/28/head
Dimas Restu H 4 years ago
parent
commit
69b27db872
  1. 5
      internal/whatsapp/whatsapp.go

5
internal/whatsapp/whatsapp.go

@ -89,11 +89,11 @@ func sendMedia(c echo.Context, mediaType string) error {
// If Media Type is "image" and MIME Type is "image/webp"
// Then Convert it as PNG
var fileBytes []byte
if mediaType == "image" && fileType == "image/webp" {
isConvertMediaImageWebP := false
isConvertMediaImageWebP, _ = env.GetEnvBool("WHATSAPP_MEDIA_IMAGE_CONVERT_WEBP")
if isConvertMediaImageWebP {
if mediaType == "image" && fileType == "image/webp" && isConvertMediaImageWebP {
// Decode WebP Image
fileWebP, err := webp.Decode(fileStream)
if err != nil {
@ -111,7 +111,6 @@ func sendMedia(c echo.Context, mediaType string) error {
// To New Encoded PNG Image and File Type to "image/png"
fileBytes = filePNG.Bytes()
fileType = "image/png"
}
} else {
// Convert File Stream in to Bytes
// Since WhatsApp Proto for Media is only Accepting Bytes format

Loading…
Cancel
Save