I'm trying to get information about scanned images that are saved into PDF files through iText (using Java).
I can get width and height (either through
Matrix, or through
The idea was to use the answer here to calculate the DPI, but I am a bit lost.
Are these values (width and height) in pixels or points? Is there any other way to achieve this?
There are a lot of answers on how to scale and save an image to a PDF file, but I didn't find any on how to read the width/height/scale
of an image and be confident about the result.
Let's split this problem into two separate problems. To calculate the DPI, you need two sets of values: a number of pixels and a distance in inch.
Now you can calculate the DPI in the x direction like this:
wPx / wInch and the DPI in the y direction like this:
hPx / hInch.