I'm trying to resize images into thumbnails in a .NET Core C# application using SixLabors.ImageSharp (version 1.0.0-beta0007). I've noticed that for only certain images, the resized image has a white, red, or blue distorted border, like so:
My code for generating the thumbnail is as follows:
using (var imageToResize = Image.Load(inStream, out IImageFormat imageFormat))
{
var size = GetThumbnailSize(imageToResize.Size()); //max size 150,preserves aspect-ratio
imageToResize.Mutate(x => x.Resize(new ResizeOptions()
{
Size = size,
Mode = ResizeMode.Crop
}));
using (var memorystream = new MemoryStream())
{
imageToResize.Save(memorystream , imageFormat);
ms.Position = 0;
outputStream.UploadFromStreamAsync(memorystream);
}
}
These two images were captured from the same device, and both have the same dimension (3024x4032) and these are the only similarities I could notice as I am a novice to image processing. I've also played around with the resize modes and different Resamplers, but could not resolve this.
What is causing this issue? Is there any way to fix this by using the SixLabors.ImageSharp library?