WebP files seems to sometimes contain ancillary data #1863
-
See #1863 (comment) I'm currently working with ImageSharp 2.0.0-alpha.0.119 from MyGet. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
The Webp encoder is a port of libwebp (cwebp), so the file sizes should actually be the same. If that's not the case, maybe there is an issue. Can you provide an example? Also make sure to use the same settings in cwebp and ImageSharp for encoding. |
Beta Was this translation helpful? Give feedback.
-
I think I misidentified the problem. 99% sure there is an issue though. using var srcImg = Image.Load(@"src.jpg");
var bmpEncoder = new BmpEncoder()
{
BitsPerPixel = BmpBitsPerPixel.Pixel32,
SupportTransparency = true,
};
var webpEncoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossless,
Method = WebpEncodingMethod.BestQuality,
};
{
using var mstream = new MemoryStream();
srcImg.Save(mstream, webpEncoder);
Console.WriteLine($"WebP length before bmp = {mstream.Length} bytes");
}
{
using var mstream = new MemoryStream();
srcImg.Save(mstream, bmpEncoder);
Console.WriteLine($"Bmp Length = {mstream.Length} bytes");
}
{
using var mstream = new MemoryStream();
srcImg.Save(mstream, webpEncoder);
Console.WriteLine($"WebP length after bmp = {mstream.Length} bytes");
} Output:
Somehow, saving the image as a bmp causes the size of a webp after it to increase significantly. Perhaps the entirety of some internal buffer is being written to the output, instead of just a slice of it? If I add a |
Beta Was this translation helpful? Give feedback.
-
I have opened an issue for this: #1872 I think, i have found the reason for this issue. Opened a Pull request to fix this: #1873 edit: @jubilant-enigma could you try version |
Beta Was this translation helpful? Give feedback.
I have opened an issue for this: #1872
I think, i have found the reason for this issue.
Opened a Pull request to fix this: #1873
edit: @jubilant-enigma could you try version
SixLabors.ImageSharp.2.0.0-alpha.0.124
to confirm the issue is fixed?