File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/ImageSharp.Web/Processors Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 44using System . Collections . Generic ;
55using System . Globalization ;
66using Microsoft . Extensions . Logging ;
7+ using SixLabors . ImageSharp . Advanced ;
78using SixLabors . ImageSharp . Formats . Jpeg ;
89using SixLabors . ImageSharp . Web . Commands ;
910
@@ -38,9 +39,19 @@ public FormattedImage Process(
3839 {
3940 if ( commands . ContainsKey ( Quality ) && image . Format is JpegFormat )
4041 {
42+ var reference =
43+ ( JpegEncoder ) image . Image
44+ . GetConfiguration ( )
45+ . ImageFormatsManager
46+ . FindEncoder ( image . Format ) ;
47+
4148 // The encoder clamps any values so no validation is required.
4249 int quality = parser . ParseValue < int > ( commands . GetValueOrDefault ( Quality ) , culture ) ;
43- image . Encoder = new JpegEncoder ( ) { Quality = quality } ;
50+
51+ if ( quality != reference . Quality )
52+ {
53+ image . Encoder = new JpegEncoder ( ) { Quality = quality , Subsample = reference . Subsample } ;
54+ }
4455 }
4556
4657 return image ;
You can’t perform that action at this time.
0 commit comments