S
shapper
Hello,
I am converting PDF files pages to PNG images.
I can control the DPI of the obtained image ...
With 96 DPI I am getting an image with around 780px.
I need the image to be 900px width.
I am using the following to scale the image:
public static Bitmap Scale(Bitmap image, Double ratio) {
return Scale(image, ratio, InterpolationMode.High);
} // Scale
public static Bitmap Scale(Bitmap image, Double ratio,
InterpolationMode mode) {
Bitmap scaled = new Bitmap((Int32)(image.Width * ratio), (Int32)
(image.Height * ratio));
using (Graphics graphics = Graphics.FromImage(scaled)) {
graphics.InterpolationMode = mode;
graphics.DrawImage(image, new Rectangle(0, 0, scaled.Width,
scaled.Height), new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}
return scaled;
} // Scale
So I scaled it but the letters seems a little bit fuzzy ... not much
but still.
I am using InterpolationMode.High ... I know that if I use
InterpolationMode.Bicubic it will take a little bit more time but I
don't think this is an issues since I am doing this only once when the
file is uploaded or updated.
With 192DPI they get to big: 142KB ... I am serving around 5 images on
a page.
Maybe I should go for 120DPI and Bicubic interpolation.
Should I change some setup on my scaling?
Should I use Image Magick?
Any suggestion to find a configuration that allows me to scale the
image to 900px and have a good quality and not a really big file is
welcome.
Thanks,
Miguel
I am converting PDF files pages to PNG images.
I can control the DPI of the obtained image ...
With 96 DPI I am getting an image with around 780px.
I need the image to be 900px width.
I am using the following to scale the image:
public static Bitmap Scale(Bitmap image, Double ratio) {
return Scale(image, ratio, InterpolationMode.High);
} // Scale
public static Bitmap Scale(Bitmap image, Double ratio,
InterpolationMode mode) {
Bitmap scaled = new Bitmap((Int32)(image.Width * ratio), (Int32)
(image.Height * ratio));
using (Graphics graphics = Graphics.FromImage(scaled)) {
graphics.InterpolationMode = mode;
graphics.DrawImage(image, new Rectangle(0, 0, scaled.Width,
scaled.Height), new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}
return scaled;
} // Scale
So I scaled it but the letters seems a little bit fuzzy ... not much
but still.
I am using InterpolationMode.High ... I know that if I use
InterpolationMode.Bicubic it will take a little bit more time but I
don't think this is an issues since I am doing this only once when the
file is uploaded or updated.
With 192DPI they get to big: 142KB ... I am serving around 5 images on
a page.
Maybe I should go for 120DPI and Bicubic interpolation.
Should I change some setup on my scaling?
Should I use Image Magick?
Any suggestion to find a configuration that allows me to scale the
image to 900px and have a good quality and not a really big file is
welcome.
Thanks,
Miguel