From d770d603c0e7fe07c2ae9c94b93f1ae3fc29597c Mon Sep 17 00:00:00 2001 From: Dmitry Pokidov Date: Tue, 15 Sep 2020 21:55:01 +1000 Subject: [PATCH] Using lower AVIF quality for lower input quality --- img/processor/imagemagick.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/img/processor/imagemagick.go b/img/processor/imagemagick.go index d147cbd..8452714 100644 --- a/img/processor/imagemagick.go +++ b/img/processor/imagemagick.go @@ -283,13 +283,16 @@ func getConvertFormatOptions(inf *ImageInfo) []string { } func getQualityOptions(inf *ImageInfo, outputMimeType string) []string { - if outputMimeType == "image/avif" { + if inf.quality == 100 { + return []string{"-quality", "82"} + } + + if outputMimeType == "image/avif" && inf.quality > 85 { return []string{"-quality", "70"} } - //Changing quality if it wasn't set in the original image - if inf.quality == 100 { - return []string{"-quality", "82"} + if outputMimeType == "image/avif" && inf.quality <= 85 { + return []string{"-quality", "60"} } return []string{}