Best config for OCR-ready PNGs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
## Question about an existing feature
### What are you trying to achieve?
We are trying to achieve the best possible (most accurate) OCR results. Images will be of invoices and receipts taken by users with their phones mostly.
We want to downscale unnecessary large images and try to reduce AI token usage by sending less pixels.
### Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
Current config:
```ts
export async function optimizeImage(buffer: Buffer): Promise {
const processedBuffer = await sharp(buffer)
.rotate()
.resize({
width: 2000,
height: 2000,
withoutEnlargement: true,
fit: 'inside',
})
.grayscale()
.normalise()
.sharpen({
sigma: 1.2,
m1: 0.5,
m2: 0.5,
})
.png()
.toBuffer()
return processedBuffer
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the optimizeImage entry point and the existing sharp pipeline shown in the issue. Compare the current output against representative invoice and receipt images, then define a supported configuration and measurable OCR-quality and image-size criteria for considering the question answered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- computer-vision, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100