print('imagePath='+imagePath) pdfDoc=fitz.open(pdfPath) for pg in range(pdfDoc.page_count): page=pdfDoc[pg] rotate=int(0) zoom_x=1.33333333 zoom_y=1.33333333 mat=fitz.Matrix(zoom_x,zoom_y).prerotate(rotate) pix=page.get_pixmap(matrix=mat,alpha=False)
if not os.path.exists(imagePath): os.makedirs(imagePath) pix.save(imagePath+'/'+'image_%s.png'%pg) endTime_pdf2img=datetime.datetime.now() # 结束时间 print('pdf2img时间=',(endTime_pdf2img-startTime_pdf2img).seconds)
if __name__=='__main__': pdfPath='/home/tellw/桌面/test2.html.pdf' imagePath='./imgs' pyMuPDF_fitz(pdfPath,imagePath)