Prerequisites
Description
Resize an image will lost some pixel.
Steps to Reproduce
btw: _imageData is an image byte array.
public override byte[] Scale(double scaleFactor, String format)
{
this.ThrowIfDisposed();
if (scaleFactor <= 0)
{
throw new ArgumentException("scalefactor must be greate than 0", nameof(scaleFactor));
}
try
{
int width = (int)(this.Profile.PixelWidth * scaleFactor);
int height = (int)(this.Profile.PixelHeight * scaleFactor);
using (Image<Rgba32> bitmap = Image.Load(_imageData, out IImageFormat imageFormat))
{
bitmap.Mutate(x => x.Resize(width, height));
IImageFormat f = String.IsNullOrWhiteSpace(format) ? imageFormat : GetImageFormat(format);
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, f);
stream.Position = 0;
return stream.ToArray();
}
}
}
catch (Exception ex)
{
throw new ImagingException("scale error.", ex);
}
}
private IImageFormat GetImageFormat(string format)
{
IImageFormat imageFormat = SixLabors.ImageSharp.Configuration.Default.FindFormatByFileExtension(format);
if (imageFormat == null)
{
throw new ImagingException($"unsupported format:{format}。");
}
return imageFormat;
}
original Image

got result:
resize to 150px:

resize to 80px

resize to 30px

System Configuration
Visual studio 2017
<TargetFramework>netstandard1.6</TargetFramework>
- ImageSharp version: 1.0.0-beta0002
- Environment (Operating system, version and so on): Windows 10 x64
- .NET Framework version: netstandard1.6
- Additional information:
Prerequisites
DEBUGandRELEASEmodeDescription
Resize an image will lost some pixel.
Steps to Reproduce
btw: _imageData is an image byte array.
original Image
got result:
resize to 150px:

resize to 80px

resize to 30px

System Configuration
Visual studio 2017