mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Fallback from AVIF to JPEG/PNG if one of the result dimensions is smaller than 16px
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Change
|
||||||
|
- Fallback from AVIF to JPEG/PNG if one of the result dimensions is smaller than 16px.
|
||||||
|
|
||||||
## [3.5.0] - 2022-04-25
|
## [3.5.0] - 2022-04-25
|
||||||
### Add
|
### Add
|
||||||
|
@@ -265,6 +265,19 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if po.Format == imagetype.AVIF && (img.Width() < 16 || img.Height() < 16) {
|
||||||
|
if img.HasAlpha() {
|
||||||
|
po.Format = imagetype.PNG
|
||||||
|
} else {
|
||||||
|
po.Format = imagetype.JPEG
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Warningf(
|
||||||
|
"Minimal dimension of AVIF is 16, current image size is %dx%d. Image will be saved as %s",
|
||||||
|
img.Width(), img.Height(), po.Format,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
outData *imagedata.ImageData
|
outData *imagedata.ImageData
|
||||||
err error
|
err error
|
||||||
|
Reference in New Issue
Block a user