diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 135048aa4..60c209c52 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -702,19 +702,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg for (int j = 0; j < Block8x8F.Size; j++) { - int x = unscaledQuant[j]; - x = ((x * scale) + 50) / 100; - if (x < 1) - { - x = 1; - } - - if (x > 255) - { - x = 255; - } - - quant[j] = x; + int scaled = ((unscaledQuant[j] * scale) + 50) / 100; + quant[j] = Math.Clamp(scaled, 1, 255); } } }