If I remove the Resize and Extend methods then the images look sharp as original in PDF but then images are not centered in PDF. The Extend does not work without Resize and Resize produces a blurry image. Spends several hours to understand what's is causing blur in resized(downsized) images without any luck.
I have attached demo images and outputs, the output.pdf has centered but blurry images, the output-no-resize-no-extend.pdf has perfect quality images as I need the to images are no longer centered on the PDF page.
\nimages.zip
\noutput.pdf
\noutput-no-resize-no-extend.pdf
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\");\n\nvar width = image.Width / (double)fromPageSize.Width;\nvar height = image.Height / (double)fromPageSize.Height;\nvar max = Math.Max(width, height);\nvar newWidth = (int)(fromPageSize.Width * max);\nvar newHeight = (int)(fromPageSize.Height * max);\n\nimage.Extent(newWidth, newHeight, Gravity.Center);-
|
I get blurry images in PDF when making them smaller and fitting to the PDF page in the center. If I remove the I have attached demo images and outputs, the output.pdf has centered but blurry images, the output-no-resize-no-extend.pdf has perfect quality images as I need the to images are no longer centered on the PDF page. |
Beta Was this translation helpful? Give feedback.
-
|
When you resize the image you will make it smaller. When you want the best quality image you should only 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); |
Beta Was this translation helpful? Give feedback.
When you resize the image you will make it smaller. When you want the best quality image you should only
Extentthe 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):