Skip to content
Discussion options

You must be logged in to vote

Document pages in general have no "natural" resolution. You are talking about the (scanned) image from which the page was created, right?
To find the scanned image's resolution, you must first locate it, then extract it to see the resolution values:

In [1]: import fitz
In [2]: doc = fitz.open("ocr-ed.pdf")
In [3]: page = doc[0]
In [4]: page.get_images()
Out[4]: [(12, 0, 1224, 1584, 8, 'DeviceRGB', '', 'R12', 'DCTDecode')]
In [5]: page.get_image_rects(12) # check if covering full page
Out[5]: [Rect(0.0, 0.0, 612.0, 792.0)]
In [6]: # true, so extract image to see its resolutions
In [7]: img = doc.extract_image(12)
In [8]: img["xres"], img["yres"]
Out[8]: (96, 96)
In [9]: # so you can render…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@esraa-abdelmaksoud
Comment options

Answer selected by esraa-abdelmaksoud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants