How to determine the physical size of the input image


Is there a way to find out the width and height of the input file?


Yes, you can get information about image size and resolution through Image object properties. Here is an example demonstrating how you can get this data:

// C#

// Getting the size of the black-and-white plane of the input image in pixels
int sourceWidthInPixels = document.Pages[0].ImageDocument.BlackWhiteImage.Width;
int sourceHeightInPixels = document.Pages[0].ImageDocument.BlackWhiteImage.Height;

// Getting the resolution of the source image in pixels per inch
int sourceXRes = document.Pages[0].ImageDocument.SourceImageXResolution;
int sourceYRes = document.Pages[0].ImageDocument.SourceImageYResolution;

// Calculating image size in inches
double sourceWidthInInches = (float)sourceWidthInPixels / sourceXRes;
double sourceHeightInInches = (float)sourceHeightInPixels / sourceYRes;

Console.WriteLine("Width = " + sourceWidthInInches + " inches" + " Height = " + sourceHeightInInches + " inches");

Also, please keep in mind that correcting skews and some other preprocessing at image adding can change the values obtained via Image::Width and Image::Height properties. That is, they will represent the size of the "internal" image and not the original. You can find more information in the Developer's Help > API Reference > Image-Related Objects > ImageDocument.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.