mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
feat: added support for exporting DocItem to an image when page image is available (#379)
* Updated minimum docling-core version to 2.4.0 Signed-off-by: Shubham Gupta <26436285+sh-gupta@users.noreply.github.com> * Deprecated the generate_table_images option Signed-off-by: Shubham Gupta <26436285+sh-gupta@users.noreply.github.com> * Updated examples to use get_image instead of element.image Signed-off-by: Shubham Gupta <26436285+sh-gupta@users.noreply.github.com> --------- Signed-off-by: Shubham Gupta <26436285+sh-gupta@users.noreply.github.com>
This commit is contained in:
@@ -28,7 +28,6 @@ def main():
|
||||
pipeline_options = PdfPipelineOptions()
|
||||
pipeline_options.images_scale = IMAGE_RESOLUTION_SCALE
|
||||
pipeline_options.generate_page_images = True
|
||||
pipeline_options.generate_table_images = True
|
||||
pipeline_options.generate_picture_images = True
|
||||
|
||||
doc_converter = DocumentConverter(
|
||||
@@ -61,7 +60,7 @@ def main():
|
||||
output_dir / f"{doc_filename}-table-{table_counter}.png"
|
||||
)
|
||||
with element_image_filename.open("wb") as fp:
|
||||
element.image.pil_image.save(fp, "PNG")
|
||||
element.get_image(conv_res.document).save(fp, "PNG")
|
||||
|
||||
if isinstance(element, PictureItem):
|
||||
picture_counter += 1
|
||||
@@ -69,7 +68,7 @@ def main():
|
||||
output_dir / f"{doc_filename}-picture-{picture_counter}.png"
|
||||
)
|
||||
with element_image_filename.open("wb") as fp:
|
||||
element.image.pil_image.save(fp, "PNG")
|
||||
element.get_image(conv_res.document).save(fp, "PNG")
|
||||
|
||||
# Save markdown with embedded pictures
|
||||
content_md = conv_res.document.export_to_markdown(image_mode=ImageRefMode.EMBEDDED)
|
||||
|
||||
Reference in New Issue
Block a user