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
Description I am resizing image with SKBitmap.Resize method for one particular image , its resizing and rotating to 180 degree as well.
resizing to ( height , width) 200 x 200 50 x 50 1000 x 1000
Code
public Stream GetResizedImage(Stream image, ImageMaxSize size, string imageFormat) { image.Position = 0L; using (var inputStream = new SKManagedStream(image)) using (var original = SKBitmap.Decode(inputStream)) { if (original.ColorType == SKColorType.Gray8 || original.ColorType == SKColorType.Unknown) { original.CopyTo(original, SKImageInfo.PlatformColorType); } var (width, height) = ResizeKeepAspect(original.Width, original.Height, size.MaxWidth, size.MaxHeight); using (var resized = original.Resize(new SKImageInfo(width, height, original.ColorType, original.AlphaType,original.ColorSpace),SKFilterQuality.High)) { if (resized == null) { _logger.LogWarning("Failed resizing image to width {0} and height {1}; color type: {2}", width, height, original.ColorType); return null; } using (var newImage = SKImage.FromBitmap(resized)) { return newImage.Encode(GetImageFormat(imageFormat), 85).AsStream(); } } } }
Expected Behavior
Image should be resized only
Actual Behavior
Images resized & rotated to 180 degree as well
Basic Information
Screenshots
Reproduction Link
The text was updated successfully, but these errors were encountered:
Further If I save as same image as .PNG , Now I can resize this PNG without issue
Sorry, something went wrong.
I can reproduce this with all images with portrait orientation. Images with Landscape orientation remain correctly aligned.
My code looks like this:
public static async Task<string?> GetResizedPngImageAsBase64String(this System.IO.Stream inputStream, long streamSize, int maxHeight, int maxWidth) { var inputBuffer = new byte[streamSize]; await inputStream.ReadAsync(inputBuffer); using var original = SKBitmap.Decode(inputBuffer); var scaleHeight = maxHeight / (float) original.Height; var scaleWidth = maxWidth / (float) original.Width; var scale = Math.Min(scaleHeight, scaleWidth); var width = (int)(original.Width * scale); var height = (int)(original.Height * scale); using var resized = original.Resize(new SKImageInfo(width, height), SKFilterQuality.High); if (resized == null) { return null; } using var image = SKImage.FromBitmap(resized); var buffer = image.Encode(SKEncodedImageFormat.Png, 100).ToArray(); var result = Convert.ToBase64String(buffer); return result; }
Used Package Version: 2.80.3 Framework: net6.0
More image stuff.. issues with SkiaSharp
ff33180
mono/SkiaSharp#923
HI I run into the same issue. Is this Bug still open ? Is there a workaround?
No branches or pull requests
Description
I am resizing image with SKBitmap.Resize method for one particular image , its resizing and rotating to 180 degree as well.
resizing to ( height , width)
200 x 200
50 x 50
1000 x 1000
Code
Expected Behavior
Image should be resized only
Actual Behavior
Images resized & rotated to 180 degree as well
Basic Information
Target Devices:
Screenshots
Reproduction Link
The text was updated successfully, but these errors were encountered: