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" // If Media Type is "image" and MIME Type is "image/webp"
// Then Convert it as PNG // Then Convert it as PNG
var fileBytes []byte var fileBytes []byte
if mediaType == "image" && fileType == "image/webp" {
isConvertMediaImageWebP := false isConvertMediaImageWebP := false
isConvertMediaImageWebP, _ = env.GetEnvBool("WHATSAPP_MEDIA_IMAGE_CONVERT_WEBP") isConvertMediaImageWebP, _ = env.GetEnvBool("WHATSAPP_MEDIA_IMAGE_CONVERT_WEBP")
if isConvertMediaImageWebP {
if mediaType == "image" && fileType == "image/webp" && isConvertMediaImageWebP {
// Decode WebP Image // Decode WebP Image
fileWebP, err := webp.Decode(fileStream) fileWebP, err := webp.Decode(fileStream)
if err != nil { 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" // To New Encoded PNG Image and File Type to "image/png"
fileBytes = filePNG.Bytes() fileBytes = filePNG.Bytes()
fileType = "image/png" fileType = "image/png"
}
} else { } else {
// Convert File Stream in to Bytes // Convert File Stream in to Bytes
// Since WhatsApp Proto for Media is only Accepting Bytes format // Since WhatsApp Proto for Media is only Accepting Bytes format

Loading…
Cancel
Save