We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEBUG
RELEASE
Resize an image will lost some pixel.
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
resize to 150px:
resize to 80px
resize to 30px
Visual studio 2017
<TargetFramework>netstandard1.6</TargetFramework>
The text was updated successfully, but these errors were encountered:
Hi @endink
I'm able to resize and save the image to 150 x150 without issue. Are you sure all your variables are correct?
Sorry, something went wrong.
@JimBobSquarePants well, I'll check my code again, and if possible, I'll extract my main code and package it up and upload it.
@JimBobSquarePants sorry, it works well now, my code writes less bytes when I write a byte array to a file
No worries, glad you found a solution. 👍
No branches or pull requests
Prerequisites
DEBUG
andRELEASE
modeDescription
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
The text was updated successfully, but these errors were encountered: