Skip to content

Commit

Permalink
Improve error for thumbnails during dimension checks
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Feb 12, 2023
1 parent 61dd5f6 commit 0a10224
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Swap out the HEIF library for better support towards [ARM64 Docker Images](https://github.com/turt2live/matrix-media-repo/issues/365).
* The development environment now uses Synapse as a homeserver. Test accounts will need recreating.
* Updated to Go 1.18
* Improved error message when thumbnailer cannot determine image dimensions.

### Fixed

Expand Down
5 changes: 3 additions & 2 deletions thumbnailing/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package thumbnailing

import (
"errors"
"github.com/turt2live/matrix-media-repo/common"
"io"
"io/ioutil"
"reflect"

"github.com/turt2live/matrix-media-repo/common"

"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/thumbnailing/i"
"github.com/turt2live/matrix-media-repo/thumbnailing/m"
Expand Down Expand Up @@ -45,7 +46,7 @@ func GenerateThumbnail(imgStream io.ReadCloser, contentType string, width int, h
// https://github.com/turt2live/matrix-media-repo/security/advisories/GHSA-j889-h476-hh9h
dimensional, w, h, err := generator.GetOriginDimensions(b, contentType, ctx)
if err != nil {
return nil, err
return nil, errors.New("error getting dimensions: " + err.Error())
}
if dimensional && (w*h) >= ctx.Config.Thumbnails.MaxPixels {
ctx.Log.Warn("Image too large: too many pixels")
Expand Down

0 comments on commit 0a10224

Please sign in to comment.