Bad quality when resize and crop an image #1627
-
Hello! using Image image = await Image.LoadAsync(file);
image.Mutate(i => i.Resize(new ResizeOptions // resize
{
Size = size,
Mode = ResizeMode.Min
})
.Resize(new ResizeOptions // crop
{
Size = size,
Mode = ResizeMode.Crop,
Position = AnchorPositionMode.Center
}) And here is the image that i'm trying to resize and crop What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
JimBobSquarePants
May 13, 2021
Replies: 1 comment 1 reply
-
You're resampling the image 2x which is going to cause a loss of information. You don't actually need to do that, With my following test code: using (var image = Image.Load<Rgba32>(Path.Combine(inPath, "1627.jpg")))
{
Size size = new Size(325, 185);
image.Mutate(i => i.Resize(
new ResizeOptions
{
Size = size,
Mode = ResizeMode.Crop,
Position = AnchorPositionMode.Center
}));
image.Save(Path.Combine(outPath, "1627.jpg"));
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're resampling the image 2x which is going to cause a loss of information. You don't actually need to do that,
ResizeMode.Crop
gives you the expected output.With my following test code:
Before
After