diff --git a/CHANGELOG.md b/CHANGELOG.md index 53f79984..47908f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Change +- Fallback from AVIF to JPEG/PNG if one of the result dimensions is smaller than 16px. ## [3.5.0] - 2022-04-25 ### Add diff --git a/processing/processing.go b/processing/processing.go index 56babcca..c27c9b33 100644 --- a/processing/processing.go +++ b/processing/processing.go @@ -265,6 +265,19 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options 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 ( outData *imagedata.ImageData err error