Inferring image DPI from pptx file

Signed-off-by: Maksym Lysak <mly@zurich.ibm.com>
This commit is contained in:
Maksym Lysak 2024-11-18 14:06:43 +01:00
parent 22400089c0
commit b132c68a32
2 changed files with 4 additions and 2 deletions

View File

@ -273,6 +273,8 @@ class MsPowerpointDocumentBackend(DeclarativeDocumentBackend, PaginatedDocumentB
# Get the image bytes
image = shape.image
image_bytes = image.blob
im_dpi, _ = image.dpi
# Open it with PIL
pil_image = Image.open(BytesIO(image_bytes))
@ -280,7 +282,7 @@ class MsPowerpointDocumentBackend(DeclarativeDocumentBackend, PaginatedDocumentB
prov = self.generate_prov(shape, slide_ind, "")
doc.add_picture(
parent=parent_slide,
image=ImageRef.from_pil(image=pil_image, dpi=72),
image=ImageRef.from_pil(image=pil_image, dpi=im_dpi),
caption=None,
prov=prov,
)

View File

@ -127,7 +127,7 @@
"footnotes": [],
"image": {
"mimetype": "image/png",
"dpi": 72,
"dpi": 300,
"size": {
"width": 268.0,
"height": 268.0