fix(image): support upload jog images

This commit is contained in:
buttercannfly 2023-09-19 15:30:56 +08:00 committed by GitHub
parent 7a6acc5967
commit 541c35e827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -12,13 +12,15 @@ func IsSupportedImageFile(file io.Reader, ext string) bool {
ext = strings.TrimPrefix(ext, ".")
var err error
switch strings.ToUpper(ext) {
case "JPG", "JPEG":
case "JPEG":
_, err = jpeg.Decode(file)
case "PNG":
_, err = png.Decode(file)
case "ICO":
// TODO: There is currently no good Golang library to parse whether the image is in ico format.
return true
case "JPG":
return true
default:
return false
}