docling icon indicating copy to clipboard operation
docling copied to clipboard

is it good enough if we use just one of them? and which one among generate_page_images, generate_picture_images is better based on both time and performance(also quantify it which one is how much better)

Open madmaxtwentytwo opened this issue 1 year ago • 3 comments

pipeline_options = PdfPipelineOptions( generate_page_images=True, generate_picture_images=True, images_scale=2.0, # other options... )

madmaxtwentytwo avatar Aug 19 '25 09:08 madmaxtwentytwo

Yes, it's usually fine to use just one of generate_page_images or generate_picture_images, depending on your downstream needs. Page images give you full-page scans, while picture images extract individual illustrations or graphics from each page. Both options increase processing time and memory usage, especially with higher images_scale values or large documents, so only enable what you actually need for your task docling Knowledge Store.

There's no official benchmark directly comparing the two, but enabling both will always be slower and use more memory than enabling just one. For most use cases, pick the one that matches your requirements: use page images for full-page context, or picture images for fine-grained content. To quantify the difference in your environment, enable pipeline profiling with profile_pipeline_timings=True—this will show you exactly how much time each step takes profiling example.

For best performance, use the default images_scale (1.0) unless you need high-res images, and only enable the image types you need usage advice.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about docling Share Dosu with your team

dosubot[bot] avatar Aug 19 '25 09:08 dosubot[bot]

from typing import Iterator

from docling.datamodel.base_models import InputFormat from docling.datamodel.document import ConversionResult from docling.datamodel.pipeline_options import PdfPipelineOptions from docling.datamodel.settings import settings from docling.document_converter import DocumentConverter, PdfFormatOption from docling_core.types import DoclingDocument

def test_regular_page() -> DoclingDocument:

urls = ['https://www.chinaxiantour.com/chengdu-travel-guide/how-to-eat-hot-pot.html']
# urls = ['https://arxiv.org/pdf/2502.15214']

pipeline_options = PdfPipelineOptions(
    generate_page_images=True,
    generate_picture_images=True,
    generate_table_images=True,
    do_code_enrichment=False,
    do_formula_enrichment=False,
    do_picture_classification=True,
    do_picture_description=False,
    images_scale=2,
)

converter = (DocumentConverter(
    format_options={
        InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options),
    })
)
# Enable the profiling to measure the time spent
settings.debug.profile_pipeline_timings = True

res_iter: Iterator[ConversionResult] = converter.convert_all(source=urls)
res = next(iter(res_iter))

# List with total time per document
doc_conversion_secs = res.timings["pipeline_total"].times
print(f"Conversion secs: {doc_conversion_secs}")

return res.document

if name == 'main':

doc = test_regular_page()

tell me about each setting and tell me which one is better for which situation using proper real world examples

madmaxtwentytwo avatar Aug 19 '25 10:08 madmaxtwentytwo

Here’s a breakdown of each setting in your PdfPipelineOptions and when to use them, with practical examples:

  • generate_page_images: Produces images of entire PDF pages. Use this for tasks needing full-page context, like document archiving, visual QA, or when downstream models (e.g., OCR, layout analysis) benefit from seeing the whole page. Example: digitizing old books or legal documents for archival purposes. This is more resource-intensive if pages are large or numerous docling code.

  • generate_picture_images: Extracts only individual pictures, illustrations, or graphics from each page. Use this for extracting figures, diagrams, or photos for image classification, captioning, or dataset creation. Example: mining scientific papers for embedded charts or extracting product images from catalogs. Less resource-intensive than page images if the document has few pictures, but can be heavy if there are many docling code.

  • generate_table_images: Deprecated. For table images, set generate_page_images=True and use TableItem.get_image after conversion docling code.

  • do_code_enrichment: Runs OCR specifically on code snippets. Use for technical documents or programming books where extracting code is important. Example: scraping code samples from PDFs of programming tutorials docling code.

  • do_formula_enrichment: Runs OCR on formulas, returning LaTeX code. Use for scientific papers, math textbooks, or any document where formulas need to be extracted and digitized docling code.

  • do_picture_classification: Classifies extracted pictures. Use for building datasets, automating tagging, or filtering images by type. Example: sorting images from a product catalog by category docling code.

  • do_picture_description: Generates captions/descriptions for pictures. Useful for accessibility (alt text), search, or content enrichment. Example: adding descriptions to images in educational materials docling code.

  • images_scale: Controls image resolution. Default is 1.0. Higher values (like 2.0) increase image quality but also processing time and memory usage. Use higher scale only if you need high-res images for downstream tasks (e.g., fine-grained OCR, image analysis). For most cases, stick to 1.0 for best performance performance advice.

Performance tips:

  • Only enable the image types you need. Enabling both page and picture images increases processing time and memory usage, especially with high images_scale or large documents performance advice.
  • For most workflows, pick either page images (for full context) or picture images (for fine-grained content), not both.
  • Use pipeline profiling (profile_pipeline_timings=True) to measure actual time spent on each step in your environment profiling advice.
  • Avoid unnecessary enrichment steps unless you need them for your downstream task.

Real-world examples:

  • Archiving scanned books: generate_page_images=True, images_scale=1.0
  • Mining figures from research papers: generate_picture_images=True, do_picture_description=True
  • Extracting code from programming PDFs: do_code_enrichment=True
  • Building a product image dataset: generate_picture_images=True, do_picture_classification=True

Let me know if you want more specific advice for your workflow!

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about docling Share Dosu with your team

dosubot[bot] avatar Aug 19 '25 10:08 dosubot[bot]