fix: make sure generating blur hashes for bmp, tiff and webp images works
This commit is contained in:
parent
3ccc6365a6
commit
8bf0f8bb57
2 changed files with 11 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
|||
package migration
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
|
||||
"code.vikunja.io/api/pkg/files"
|
||||
|
@ -64,9 +65,12 @@ func init() {
|
|||
}
|
||||
|
||||
src, _, err := image.Decode(bgFile.File)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, image.ErrFormat) {
|
||||
return err
|
||||
}
|
||||
if err != nil && errors.Is(err, image.ErrFormat) {
|
||||
log.Warningf("Could not generate a blur hash of list %d's background image: %s", l.ID, err)
|
||||
}
|
||||
|
||||
dst := image.NewRGBA(image.Rect(0, 0, 32, 32))
|
||||
draw.NearestNeighbor.Scale(dst, dst.Rect, src, src.Bounds(), draw.Over, nil)
|
||||
|
|
|
@ -17,10 +17,15 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"image"
|
||||
_ "image/gif" // To make sure the decoder used for generating blurHashes recognizes gifs
|
||||
_ "image/jpeg" // To make sure the decoder used for generating blurHashes recognizes jpgs
|
||||
_ "image/png" // To make sure the decoder used for generating blurHashes recognizes pngs
|
||||
|
||||
_ "golang.org/x/image/bmp" // To make sure the decoder used for generating blurHashes recognizes bmps
|
||||
_ "golang.org/x/image/tiff" // To make sure the decoder used for generating blurHashes recognizes tiffs
|
||||
_ "golang.org/x/image/webp" // To make sure the decoder used for generating blurHashes recognizes tiffs
|
||||
|
||||
"image"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
|
Loading…
Reference in a new issue