docling-project / docling-project/docling
Bad OCR quality due to double image resize
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
I'm using VLM model for OCR task.
My converter uses default backend for ImageFormatOption. In ApiVlmOptions for images i use scale=1
I noticed that when i making api call to VLM from jupyter notebook (without resizing) — result is perfect. But when i make same request with same image to the same VLM over Docling converter — result is much worse.
After few hours i realized that difference in ocr quality comes from image quality. Just look at examples below.
Here is original image:

And here is an image restored from base64 (from docling request) and it is not sharper as proposed in code below, it is much smoother.

As far as i understand this issue comes from this code (in every backend with get_page_image method)
```
image = (
self._ppage.render(
scale=scale * 1.5,
rotation=0, # no additional rotation
crop=padbox.as_tuple(),
)
.to_pil()
.resize(size=(round(cropbox.width * scale), round(cropbox.height * scale)))
) # We resize the image from 1.5x the given scale to make it sharper.
```
Can we just drop this double scaling?
### Steps to reproduce
Dump image in `api_image_request` function.
### Docling version
2.37.0
### Python version
3.12
Contributor guide
Assessment
This issue has not been assessed yet.