docling icon indicating copy to clipboard operation
docling copied to clipboard

what are page images and picture images

Open madmaxtwentytwo opened this issue 1 year ago • 8 comments

explain with an example

madmaxtwentytwo avatar Aug 19 '25 09:08 madmaxtwentytwo

In Docling, "page images" are images of entire document pages, like a scanned page from a book or PDF. "Picture images" are images of individual pictures, illustrations, or graphics found within those pages. You can control whether these images are generated using pipeline configuration options: generate_page_images for full pages and generate_picture_images for pictures within pages.

For example, to enable both types during PDF processing, you might use:

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

This setup will produce images for each page and for each picture found inside the pages during document conversion. More details on these options are available in the Docling documentation and issues (source, source).

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about docling with Dosu Add Dosu to your team

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

def convert_document(file_path): """Convert document to markdown with proper image extraction configuration""" start_time = time.time() logger.info(f"Starting document conversion: {file_path}")

try:
    # Configure pipeline options for proper image extraction
    pipeline_options = PdfPipelineOptions()
    pipeline_options.images_scale = 2
    pipeline_options.generate_page_images = True
    pipeline_options.generate_picture_images = True
    
    # Create DocumentConverter with proper format options
    converter = DocumentConverter(
        format_options={
            InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
        }
    )
    
    result = converter.convert(file_path)
    markdown_content = result.document.export_to_markdown()
    
    conversion_time = time.time() - start_time
    logger.info(f"Document conversion completed in {conversion_time:.2f}s - Markdown length: {len(markdown_content)} chars")
    
    return markdown_content, result
    
except Exception as e:
    logger.error(f"Document conversion failed after {time.time() - start_time:.2f}s: {str(e)}")

this is what im using check which of the setting is taking more time and also tell me which can be changed and why to make my code faster and efficient

madmaxtwentytwo avatar Aug 19 '25 09:08 madmaxtwentytwo

The settings that impact conversion time most are images_scale, generate_page_images, and generate_picture_images. Higher images_scale values (like 2) produce higher-resolution images, which improves OCR/model accuracy but significantly increases processing time and memory usage, especially for large documents. Enabling both generate_page_images and generate_picture_images means the pipeline extracts images for every page and every picture, adding extra processing steps and slowing things down docling Knowledge Store.

To make your code faster and more efficient:

  • Use the default images_scale (usually 1.0) unless you need high accuracy for small text or detailed images.
  • Disable generate_page_images or generate_picture_images if you don't need both types of images.
  • Avoid enabling enrichment steps (like picture classification/description) unless necessary, as these add more processing docling Knowledge Store.

If you want to see exactly which step takes the most time, you can enable pipeline profiling by setting profile_pipeline_timings=True in your debug settings. This will record timing data for each pipeline step in the result.timings dictionary, so you can analyze where the bottlenecks are docling/utils/profiling.py.

Let me know if you want details on how to enable profiling or tune other pipeline options!

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]

what is the use of generate_page_images and generate_picture_images function

madmaxtwentytwo avatar Aug 19 '25 09:08 madmaxtwentytwo

The generate_page_images and generate_picture_images options are configuration flags in Docling's pipeline, not functions. When you enable generate_page_images, the pipeline generates images for entire document pages (like full-page scans) and attaches them to the output structure. When you enable generate_picture_images, it generates images for individual pictures or illustrations found within those pages by cropping the relevant area from the page image and attaching it to each PictureItem in the output. Both options increase processing time and memory usage, especially with high image scales or large documents, so only enable what you actually need for your downstream tasks. For most use cases, you can leave these off unless you specifically need page-level or picture-level images in your output (source).

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about docling with Dosu Add Dosu to your team

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

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

madmaxtwentytwo avatar Aug 19 '25 09:08 madmaxtwentytwo

@dosu how can i enable profiling, can you supply a code example?

ofcat avatar Mar 10 '26 13:03 ofcat

To enable profiling, import the global settings object and set profile_pipeline_timings to True before running your conversion:

from docling.datamodel.settings import settings
from docling.document_converter import DocumentConverter
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.document_converter import PdfFormatOption
from docling.datamodel.base_models import InputFormat

# Enable profiling
settings.debug.profile_pipeline_timings = True

# Your existing pipeline options
pipeline_options = PdfPipelineOptions()
pipeline_options.images_scale = 2
pipeline_options.generate_page_images = True
pipeline_options.generate_picture_images = True

converter = DocumentConverter(
    format_options={
        InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
    }
)

result = converter.convert(file_path)

# Access timing data
print(f"Total pipeline time: {result.timings['pipeline_total'].times[0]:.2f}s")

# Print all available stages
for stage_name, profiling_item in result.timings.items():
    print(f"{stage_name}: {profiling_item.total():.2f}s")

The result.timings dictionary contains timing data for each pipeline stage. The ProfilingItem objects provide useful methods like total(), avg(), std(), and percentile() for detailed analysis (settings.py, profiling.py).

This will help you identify exactly which pipeline stages are taking the most time so you can optimize accordingly.

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 Mar 10 '26 14:03 dosubot[bot]