Skip to content

Conversation

@kerivin
Copy link

@kerivin kerivin commented Jun 26, 2025

I left a comment in issue #13294 about brightness/contrast of scanned PDFs. But then I saw the amount of open issues in the main koreader repo and decided to experiment myself, and I think I might have found a decent solution for this.
The solution would contain 3 pull requests (for koreader, koreader-base (this one) and libk2pdfopt) and would add option 'white threshold'. libk2pdfopt natively has it (and I created a pull request for it as well), but for MuPDF (here in koreader-base) I had to write my implementation, and it actually looks quite good:

I know literally nothing about Lua or contributing to open source, so chances I've made a mistake somewhere are not zero, please keep in mind.


This change is Reviewable

@Frenzie
Copy link
Member

Frenzie commented Jun 26, 2025

I'm not sure if a custom implementation necessarily makes sense if libk2pdfopt already has it? If a custom implementation does make sense it feels more like a generic thing than something specific for MuPDF.

@benoit-pierre
Copy link
Member

I've not looked at what libk2pdfopt does, but leptonica provides some function for gamma correction and contrast enhancement, no?

@kerivin
Copy link
Author

kerivin commented Jun 26, 2025

I also experimented with libk2pdf because yes, it does have native white threshold and it works, but I thought it's a good thing to have regardless of whether Dewatermark is on or off.

@kerivin kerivin changed the title #13294 Brightness/contrast for scanned PDFs (MuPDF) White threshold for scanned PDFs (MuPDF) Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants