mirror of
https://github.com/BluemediaDev/ScanOS.git
synced 2025-05-05 01:41:36 +02:00
Add OCR and image correction
This commit is contained in:
parent
e74d3a4e27
commit
e93117aeb4
13 changed files with 228 additions and 20 deletions
0
backend/app/backends/__init__.py
Normal file
0
backend/app/backends/__init__.py
Normal file
16
backend/app/backends/common.py
Normal file
16
backend/app/backends/common.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from PIL import Image
|
||||
import ocrmypdf
|
||||
|
||||
def create_pdf(scanner):
|
||||
images = []
|
||||
for page in scanner.get_pages():
|
||||
img = Image.open(f"/var/www/html/img/{page.filename}")
|
||||
a4im = Image.new('RGB',
|
||||
(int(210 * 200 / 25.4), int(297 * 200 / 25.4)),
|
||||
(255, 255, 255))
|
||||
a4im.paste(img, img.getbbox())
|
||||
images.append(a4im)
|
||||
images[0].save("/var/www/html/img/out.pdf", save_all=True, append_images=images[1:])
|
||||
|
||||
def ocr_pdf():
|
||||
ocrmypdf.ocr('/var/www/html/img/out.pdf', '/var/www/html/img/final.pdf')
|
0
backend/app/backends/email.py
Normal file
0
backend/app/backends/email.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue