mirror of https://github.com/MISP/misp-modules
- Reverted to <3.6 compatibility
parent
9f0313a97e
commit
549f32547d
|
@ -56,16 +56,16 @@ def handler(q=False):
|
||||||
with document as pdf:
|
with document as pdf:
|
||||||
# Get number of pages
|
# Get number of pages
|
||||||
pages=len(pdf.sequence)
|
pages=len(pdf.sequence)
|
||||||
log.debug(f"PDF with {pages} page(s) detected")
|
log.debug("PDF with {} page(s) detected".format(pages))
|
||||||
# Create new image object where the height will be the number of pages. With huge PDFs this will overflow, break, consume silly memory etc…
|
# Create new image object where the height will be the number of pages. With huge PDFs this will overflow, break, consume silly memory etc…
|
||||||
img = WImage(width=pdf.width, height=pdf.height * pages)
|
img = WImage(width=pdf.width, height=pdf.height * pages)
|
||||||
# Cycle through pages and stitch it together to one big file
|
# Cycle through pages and stitch it together to one big file
|
||||||
for p in range(pages):
|
for p in range(pages):
|
||||||
log.debug(f"Stitching page {p+1}")
|
log.debug("Stitching page {}".format(p+1))
|
||||||
image = img.composite(pdf.sequence[p], top=pdf.height * p, left=0)
|
image = img.composite(pdf.sequence[p], top=pdf.height * p, left=0)
|
||||||
# Create a png blob
|
# Create a png blob
|
||||||
image = img.make_blob('png')
|
image = img.make_blob('png')
|
||||||
log.debug(f"Final image size is {pdf.width}x{pdf.height*(p+1)}")
|
log.debug("Final image size is {}x{}".format(pdf.width, pdf.height*(p+1)))
|
||||||
else:
|
else:
|
||||||
image = document
|
image = document
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue