阅读文本 / Reading text
This paper uses synthetic samples to demonstrate the processing method. The code has been verified using examples in an isolated environment; this does not guarantee effectiveness for all real-world files or products. Before processing important files, please retain the original copies and verify them against the boundaries and acceptance criteria outlined in this document.
changes the image DPI from 72 to 300; the file properties now look more professional, but the text edges remain unclear. DPI is information about physical size conversion, whereas pixels are the actual sampling points carried by the image. The two are related, but modifying metadata does not magically add glyph-level detail.
first asks about the pixel dimensions, then about the output size
Images of the same width can correspond to different print widths depending on their DPI settings. OCR input constraints typically also involve total pixel count, long-side dimension, and file size; it is not sufficient to examine only a single DPI value in the file properties. The compressed byte size likewise cannot directly indicate the memory requirements for decoding.
Compare two samples that differ only in DPI.
from io import BytesIO
from PIL import Image
image = Image.new("RGB", (600, 300), "white")
def encode(dpi):
stream = BytesIO()
image.save(stream, format="PNG", dpi=(dpi, dpi))
stream.seek(0)
decoded = Image.open(stream)
decoded.load()
return decoded
low, high = encode(72), encode(300)
assert low.size == high.size == (600, 300)
assert low.tobytes() == high.tobytes()
assert low.info["dpi"][0] < high.info["dpi"][0]
assert image.width * image.height == 180000
assert 600 / 300 == 2.0
The last line indicates that, under the 300 DPI assumption, six hundred pixels correspond to two inches. Saving a PNG’s DPI may involve unit conversion and rounding, so it should not be asserted that the read value is exactly identical to the written value bit by bit. Here, we compare the magnitudes and directly verify that the number of pixels has not changed.
Use the correct indicators for the input budget.
metric
What can it indicate?
cannot indicate anything
total pixels
basic decoding scale
Are the characters sufficiently clear?
DPI metadata
Physical dimension conversion
actual new details
file byte count
upload and storage burden
The total amount of memory after decoding
character local height
glyph sampling status
All pages are equally readable
zoom and rescan are distinct actions
If the original image has already compressed fine strokes into a single pixel, interpolation-based enlargement cannot restore the original information. When re-scanning is possible, the focus should be on improving acquisition quality; if re-scanning is not feasible, then different preprocessing methods should be compared. Any “recognition improvement” must be evaluated using the same annotated samples.
evaluation document translation first standardizes the input to
uses
OmniDoc (Product Entry)
When processing scanned documents, recording pixel dimensions and source quality helps compare results across different files. Do not assume identical conditions simply because both files are labeled 300 DPI. Clear input specifications also enable the team to determine which pages require manual review.
Reference:
Pillow Image
。
- 1 -
Updated 2026-10-08