Skip to content

Bad quality when resize and crop an image #1627

Answered by JimBobSquarePants
zn asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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"));
}

Before

After

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zn
Comment options

Answer selected by zn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants