File tree 1 file changed +12
-1
lines changed
src/ImageSharp.Web/Processors
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 4
4
using System . Collections . Generic ;
5
5
using System . Globalization ;
6
6
using Microsoft . Extensions . Logging ;
7
+ using SixLabors . ImageSharp . Advanced ;
7
8
using SixLabors . ImageSharp . Formats . Jpeg ;
8
9
using SixLabors . ImageSharp . Web . Commands ;
9
10
@@ -38,9 +39,19 @@ public FormattedImage Process(
38
39
{
39
40
if ( commands . ContainsKey ( Quality ) && image . Format is JpegFormat )
40
41
{
42
+ var reference =
43
+ ( JpegEncoder ) image . Image
44
+ . GetConfiguration ( )
45
+ . ImageFormatsManager
46
+ . FindEncoder ( image . Format ) ;
47
+
41
48
// The encoder clamps any values so no validation is required.
42
49
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
+ }
44
55
}
45
56
46
57
return image ;
You can’t perform that action at this time.
0 commit comments