Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Increase DPI from 72 to 300 does not work

$
0
0
Maybe I should add a new overload for the Resample method:
using (MagickImage image = new MagickImage("yourfile.jpg"))
{
  Density density = new Density(300, DensityUnit.PixelsPerInch);
  double width = 2.13; // inchesdouble height = 2.5; // inches
  image.Resample(density, width, height);
  /*
   * And this would do:
   * int imageWidth = 2.13 * 300; // 639
   * int imageHeight = 2.5 * 300; // 750
   * image.Density = 300;
   * image.Resize(imageWidth, imageHeight);
   */
}
The only issue with this is that the input image should have the correct dimensions. This means that you will need to do the calculation yourself anyways. You will need to do this because you either want to crop or extent the image to the required dimensions. So maybe this is a better solution:
int dpi = 300;
  double width = 2.13; // inchesdouble height = 2.5; // inches

  Density density = new Density(dpi, DensityUnit.PixelsPerInch);
  MagickGeometry geometry = density.ToGeometry(width, height);
  Console.WriteLine(geometry.ToString()); // 639x750// And you could use the geometry to resize the image.
Your thoughts?

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>