I have managed to extract images from several PDF pages with the below code, but the resolution is quite low. Is there a way to adjust that?
import fitz
pdffile = "C:\\Users\\me\\Desktop\\myfile.pdf"
doc = fitz.open(pdffile)
for page_index in range(doc.pageCount):
page = doc.loadPage(page_index)
pix = page.getPixmap()
output = "image_page_" + str(page_index) + ".jpg"
pix.writePNG(output)
I have also tried using the code here and updated if pix.n < 5" to "if pix.n - pix.alpha < 4 but this didn't output any images in my case.
pix.writePNG
becamepix.save
and more like that. This happened in v1.18.4 and is mandatory since 1.20.0. – Mallissa