mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
feat: add redirection to original image if resampled image is not available
This commit is contained in:
@@ -173,12 +173,17 @@ func deleteImage(id uint) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetResampledImage returns a resampled version of the image if it exceeds the maximum pixel limit, otherwise returns nil.
|
||||
func GetResampledImage(id uint) ([]byte, error) {
|
||||
i, err := dao.GetImageByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if i.Width*i.Height <= resampledMaxPixels {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
data, err := getOrCreateResampledImage(i)
|
||||
if err != nil {
|
||||
log.Error("Error getting or creating resampled image:", err)
|
||||
|
||||
Reference in New Issue
Block a user