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:
// Getting the size of the black-and-white plane of the input image in pixels
int sourceWidthInPixels = document.Pages.ImageDocument.BlackWhiteImage.Width;
int sourceHeightInPixels = document.Pages.ImageDocument.BlackWhiteImage.Height;
// Getting the resolution of the source image in pixels per inch
int sourceXRes = document.Pages.ImageDocument.SourceImageXResolution;
int sourceYRes = document.Pages.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.
Please sign in to leave a comment.