mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-31 22:44:27 +00:00
Inferring image DPI from pptx file
Signed-off-by: Maksym Lysak <mly@zurich.ibm.com>
This commit is contained in:
parent
22400089c0
commit
b132c68a32
@ -273,6 +273,8 @@ class MsPowerpointDocumentBackend(DeclarativeDocumentBackend, PaginatedDocumentB
|
|||||||
# Get the image bytes
|
# Get the image bytes
|
||||||
image = shape.image
|
image = shape.image
|
||||||
image_bytes = image.blob
|
image_bytes = image.blob
|
||||||
|
im_dpi, _ = image.dpi
|
||||||
|
|
||||||
# Open it with PIL
|
# Open it with PIL
|
||||||
pil_image = Image.open(BytesIO(image_bytes))
|
pil_image = Image.open(BytesIO(image_bytes))
|
||||||
|
|
||||||
@ -280,7 +282,7 @@ class MsPowerpointDocumentBackend(DeclarativeDocumentBackend, PaginatedDocumentB
|
|||||||
prov = self.generate_prov(shape, slide_ind, "")
|
prov = self.generate_prov(shape, slide_ind, "")
|
||||||
doc.add_picture(
|
doc.add_picture(
|
||||||
parent=parent_slide,
|
parent=parent_slide,
|
||||||
image=ImageRef.from_pil(image=pil_image, dpi=72),
|
image=ImageRef.from_pil(image=pil_image, dpi=im_dpi),
|
||||||
caption=None,
|
caption=None,
|
||||||
prov=prov,
|
prov=prov,
|
||||||
)
|
)
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
"footnotes": [],
|
"footnotes": [],
|
||||||
"image": {
|
"image": {
|
||||||
"mimetype": "image/png",
|
"mimetype": "image/png",
|
||||||
"dpi": 72,
|
"dpi": 300,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 268.0,
|
"width": 268.0,
|
||||||
"height": 268.0
|
"height": 268.0
|
||||||
|
Loading…
Reference in New Issue
Block a user