fix: use correct image index in word backend (#442)
* fix image index in word backend Signed-off-by: Manuel030 <manuelenrique.plank@gmail.com> * fix: Fixes for wordx (#432) * fixes for referencing drawing blip in wordx Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> * Added safety try-except when trying to load pillow image from a docx blob. Added explicit dependency on lxml. Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> * Added test for word file with embedded emf images, re-generated full tests for docx, eased up dependency on lxml Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> * Updated lxml dependency version Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> --------- Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> Co-authored-by: Maksym Lysak <mly@zurich.ibm.com> Signed-off-by: Manuel030 <manuelenrique.plank@gmail.com> * sign dco Signed-off-by: Manuel030 <manuelenrique.plank@gmail.com> * correct rebase error Signed-off-by: Manuel030 <manuelenrique.plank@gmail.com> --------- Signed-off-by: Manuel030 <manuelenrique.plank@gmail.com> Signed-off-by: Maksym Lysak <mly@zurich.ibm.com> Co-authored-by: Maxim Lysak <101627549+maxmnemonic@users.noreply.github.com> Co-authored-by: Maksym Lysak <mly@zurich.ibm.com>
This commit is contained in:
parent
29807a2d68
commit
767563bf8b
@ -507,18 +507,19 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
|
||||
image_data = get_docx_image(element, drawing_blip)
|
||||
image_bytes = BytesIO(image_data)
|
||||
level = self.get_level()
|
||||
# Open the BytesIO object with PIL to create an Image
|
||||
try:
|
||||
pil_image = Image.open(image_bytes)
|
||||
doc.add_picture(
|
||||
parent=self.parents[self.level],
|
||||
parent=self.parents[level - 1],
|
||||
image=ImageRef.from_pil(image=pil_image, dpi=72),
|
||||
caption=None,
|
||||
)
|
||||
except (UnidentifiedImageError, OSError) as e:
|
||||
_log.warning("Warning: image cannot be loaded by Pillow")
|
||||
doc.add_picture(
|
||||
parent=self.parents[self.level],
|
||||
parent=self.parents[level - 1],
|
||||
caption=None,
|
||||
)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user