summaryrefslogtreecommitdiffstats
path: root/api/file.go
diff options
context:
space:
mode:
authornickago <ngonella@calpoly.edu>2015-08-04 14:35:34 -0700
committernickago <ngonella@calpoly.edu>2015-08-04 14:35:34 -0700
commit530d4981418210080923516058895561d9d074f1 (patch)
tree7528e0b23031f77127f7f4e09c101a79fe5c478a /api/file.go
parent2c46ee8420eb19d827d3f2072bd536aae2038f84 (diff)
downloadchat-530d4981418210080923516058895561d9d074f1.tar.gz
chat-530d4981418210080923516058895561d9d074f1.tar.bz2
chat-530d4981418210080923516058895561d9d074f1.zip
Drawing all images onto a white background, thus removing transparency
Diffstat (limited to 'api/file.go')
-rw-r--r--api/file.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/api/file.go b/api/file.go
index 4ec421eb9..bf1c59422 100644
--- a/api/file.go
+++ b/api/file.go
@@ -15,6 +15,8 @@ import (
"github.com/nfnt/resize"
_ "golang.org/x/image/bmp"
"image"
+ "image/color"
+ "image/draw"
_ "image/gif"
"image/jpeg"
"io"
@@ -138,6 +140,12 @@ func fireAndForgetHandleImages(filenames []string, fileData [][]byte, teamId, ch
return
}
+ // Remove transparency due to JPEG's lack of support of it
+ temp := image.NewRGBA(img.Bounds())
+ draw.Draw(temp, temp.Bounds(), image.NewUniform(color.White), image.Point{}, draw.Src)
+ draw.Draw(temp, temp.Bounds(), img, img.Bounds().Min, draw.Over)
+ img = temp
+
// Create thumbnail
go func() {
thumbWidth := float64(utils.Cfg.ImageSettings.ThumbnailWidth)