IMGPROXY_ENFORCE_THUMBNAIL config & enforce_thumbnail option

This commit is contained in:
DarthSim
2022-04-14 22:32:40 +06:00
parent 9b146991c5
commit e1a69c5d95
6 changed files with 36 additions and 2 deletions

View File

@@ -239,8 +239,14 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
img := new(vips.Image)
defer img.Clear()
if err := img.Load(imgdata, 1, 1.0, pages); err != nil {
return nil, err
if po.EnforceThumbnail && imgdata.Type.SupportsThumbnail() {
if err := img.LoadThumbnail(imgdata); err != nil {
return nil, err
}
} else {
if err := img.Load(imgdata, 1, 1.0, pages); err != nil {
return nil, err
}
}
originWidth, originHeight := getImageSize(img)