fix image loading error causing crash. add todo.txt

This commit is contained in:
aynakeya
2024-05-06 08:19:06 +08:00
parent f24b3e73fb
commit f54e01f7ea
3 changed files with 8 additions and 2 deletions

View File

@@ -45,11 +45,14 @@ func NewImageFromPlayerPicture(picture miaosic.Picture) (*canvas.Image, error) {
return nil, errors.New("fail to fail url")
}
img = canvas.NewImageFromURI(uri)
if img == nil {
if img == nil || (img.File == "" && img.Resource == nil) {
// bug fix, return a new error to indicate fail to read an image
return nil, errors.New("fail to read image")
}
}
if img.Resource == nil {
return nil, errors.New("fail to read image")
}
// compress image, so it won't be too large
img.Resource = ResizeImage(img.Resource, 128, 128)
return img, nil