Skip to content

Blurry image when Resizing and Extending #1034

Answered by dlemstra
tomasr78 asked this question in Help
Discussion options

You must be logged in to vote

When you resize the image you will make it smaller. When you want the best quality image you should only Extent the image. You should calculate what the width and height should be to have the same aspect ratio as the page size. You can calculate that with the following method (there might be a better method to do this):

var fromPageSize = MagickGeometry.FromPageSize("a4");

var width = image.Width / (double)fromPageSize.Width;
var height = image.Height / (double)fromPageSize.Height;
var max = Math.Max(width, height);
var newWidth = (int)(fromPageSize.Width * max);
var newHeight = (int)(fromPageSize.Height * max);

image.Extent(newWidth, newHeight, Gravity.Center);

Replies: 1 comment 1 reply

Comment options

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

Answer selected by tomasr78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants