@@ -70,6 +70,7 @@ internal sealed class WebpEncoderCore : IImageEncoderInternals
7070
7171 /// <summary>
7272 /// Indicating what file format compression should be used.
73+ /// Defaults to lossy.
7374 /// </summary>
7475 private readonly WebpFileFormatType ? fileFormat ;
7576
@@ -112,43 +113,43 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
112113 Guard . NotNull ( stream , nameof ( stream ) ) ;
113114
114115 this . configuration = image . GetConfiguration ( ) ;
115- bool lossy ;
116+ bool lossless ;
116117 if ( this . fileFormat is not null )
117118 {
118- lossy = this . fileFormat == WebpFileFormatType . Lossy ;
119+ lossless = this . fileFormat == WebpFileFormatType . Lossless ;
119120 }
120121 else
121122 {
122123 WebpMetadata webpMetadata = image . Metadata . GetWebpMetadata ( ) ;
123- lossy = webpMetadata . FileFormat == WebpFileFormatType . Lossy ;
124+ lossless = webpMetadata . FileFormat == WebpFileFormatType . Lossless ;
124125 }
125126
126- if ( lossy )
127+ if ( lossless )
127128 {
128- using var enc = new Vp8Encoder (
129+ using var enc = new Vp8LEncoder (
129130 this . memoryAllocator ,
130131 this . configuration ,
131132 image . Width ,
132133 image . Height ,
133134 this . quality ,
134135 this . method ,
135- this . entropyPasses ,
136- this . filterStrength ,
137- this . spatialNoiseShaping ) ;
136+ this . transparentColorMode ,
137+ this . nearLossless ,
138+ this . nearLosslessQuality ) ;
138139 enc . Encode ( image , stream ) ;
139140 }
140141 else
141142 {
142- using var enc = new Vp8LEncoder (
143+ using var enc = new Vp8Encoder (
143144 this . memoryAllocator ,
144145 this . configuration ,
145146 image . Width ,
146147 image . Height ,
147148 this . quality ,
148149 this . method ,
149- this . transparentColorMode ,
150- this . nearLossless ,
151- this . nearLosslessQuality ) ;
150+ this . entropyPasses ,
151+ this . filterStrength ,
152+ this . spatialNoiseShaping ) ;
152153 enc . Encode ( image , stream ) ;
153154 }
154155 }
0 commit comments