fix: allow webp thumbnails (#758)

* use webp as thumbnail

* simpler way to use webp

---------

Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
This commit is contained in:
Monirzadeh 2023-10-22 13:06:08 +00:00 committed by GitHub
parent 1ae82f48a3
commit 03df5e8399
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

2
go.mod
View file

@ -34,6 +34,7 @@ require (
github.com/swaggo/swag v1.16.2
github.com/toorop/gin-logrus v0.0.0-20210225092905-2c785434f26f
golang.org/x/crypto v0.13.0
golang.org/x/image v0.12.0
golang.org/x/net v0.15.0
golang.org/x/term v0.12.0
modernc.org/sqlite v1.26.0
@ -86,7 +87,6 @@ require (
go.etcd.io/bbolt v1.3.7 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/image v0.12.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect

View file

@ -21,6 +21,7 @@ import (
"github.com/go-shiori/shiori/internal/model"
"github.com/go-shiori/warc"
"github.com/pkg/errors"
_ "golang.org/x/image/webp"
// Add support for png
_ "image/png"
@ -204,6 +205,7 @@ func DownloadBookImage(url, dstPath string) error {
if !strings.Contains(cp, "image/jpeg") &&
!strings.Contains(cp, "image/pjpeg") &&
!strings.Contains(cp, "image/jpg") &&
!strings.Contains(cp, "image/webp") &&
!strings.Contains(cp, "image/png") {
return ErrNoSupportedImageType
}