Skip to content

Commit

Permalink
Improve gif processing (mattermost#19164) (mattermost#19185)
Browse files Browse the repository at this point in the history
Automatic Merge
  • Loading branch information
mattermost-build authored Dec 15, 2021
1 parent 74e87ec commit ec15052
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"encoding/base64"
"fmt"
"image"
"image/gif"
"io"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -830,13 +829,11 @@ func (t *UploadFileTask) preprocessImage() *model.AppError {
// For animated GIFs disable the preview; since we have to Decode gifs
// anyway, cache the decoded image for later.
if t.fileinfo.MimeType == "image/gif" {
gifConfig, err := gif.DecodeAll(io.MultiReader(bytes.NewReader(t.buf.Bytes()), t.teeInput))
if err == nil {
if len(gifConfig.Image) > 0 {
t.fileinfo.HasPreviewImage = false
t.decoded = gifConfig.Image[0]
t.imageType = "gif"
}
image, format, err := t.imgDecoder.Decode(io.MultiReader(bytes.NewReader(t.buf.Bytes()), t.teeInput))
if err == nil && image != nil {
t.fileinfo.HasPreviewImage = false
t.decoded = image
t.imageType = format
}
}

Expand Down

0 comments on commit ec15052

Please sign in to comment.