content = pdf.getPage(page_index)["/Resources"]["/XObject"].getObject()
images = {}
for obj in content:
if content[obj]["/Subtype"] == "/Image":
size = (content[obj]["/Width"], content[obj]["/Height"])
data = content[obj]._data
if content[obj]["/ColorSpace"] == "/DeviceRGB":
mode = "RGB"
else:
mode = "P"
if content[obj]["/Filter"] == "/FlateDecode":
img = Image.frombytes(mode, size, data)
else:
img = Image.open(io.BytesIO(data))
images[int(obj[3:])] = img
pdf = PdfFileReader(open(args.input_pdf_path, "rb"))
for i in range(0, pdf.getNumPages()):
logger.info("Processing page {}/{}".format(i + 1, pdf.getNumPages()))
images_path.append("./temp/{}.jpg".format(i))
process_page(pdf, i, i < args.skip)
logger.info("Writing to output PDF file")
args.output.write(img2pdf.convert(*list(map(img2pdf.input_images, images_path))))
logger.info("Done")
the pdf here is the pdf file, but the / Resources and / XObject here don"t know what it means.
args.output.write (img2pdf.convert (* list (map (img2pdf.input_images, images_path)) doesn"t know what it means either
original link https://github.com/Goshin/Rem.