[#440] try to use the original image format when creating thumbs
This commit is contained in:
@@ -305,8 +305,15 @@ func (s *System) CreateThumb(originalKey string, thumbKey, thumbSize string) err
|
|||||||
return writerErr
|
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)
|
// 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()
|
w.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user