I have pdf file in which an image is embedded in it how i can get the DPI information of that particular image using python. i tried using "pdfimages" popler-util it gives me the height and width in pixels.
But how i can get the DPI of image from that.
Like the PostScript format or the EPS format, a PDF file has no resolution because it is a vectorial format. All you can do is retrieving the image dimensions in pt (or pixels):
from PyPDF2 import PdfReader
import io
with (io.open(path, mode="rb") as f):
input_pdf = PdfReader(f)
media_box = input_pdf.pages[0].mediabox
min_pt = media_box.lower_left
max_pt = media_box.upper_right
pdf_width = max_pt[0] - min_pt[0]
pdf_height = max_pt[1] - min_pt[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With