1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-24 17:07:00 +02:00

[#440] try to use the original image format when creating thumbs

This commit is contained in:
Gani Georgiev 2022-09-14 17:12:47 +03:00
parent 030dfc2690
commit 2fa5233fa6

View File

@ -305,8 +305,15 @@ func (s *System) CreateThumb(originalKey string, thumbKey, thumbSize string) err
return writerErr
}
// try to detect the thumb format based on the original file name
// (fallbacks to png on error)
format, err := imaging.FormatFromFilename(thumbKey)
if err != nil {
format = imaging.PNG
}
// thumb encode (aka. upload)
if err := imaging.Encode(w, thumbImg, imaging.PNG); err != nil {
if err := imaging.Encode(w, thumbImg, format); err != nil {
w.Close()
return err
}