Giter Site home page Giter Site logo

hocrshrink's Introduction

hOCR Shrink

A small script to scale down tesseracts html output to match smaller resolution scans

Why?

I use tesseract to OCR my scans and hocr2pdf to convert my scans into searchable pdfs. This works fine with high-dpi images (for better OCR). But sometimes you need a small pdf that doesn't need hundreds of dpi.

Sadly the html output of tesseract seems to be in pixels, and hocr2pdf uses the pixels of the scanned image to align the word boxes. So if you shrink the image to 1/4, text in the pdf is 4x too big (and out of place, of course)

This small script shrinks all bbox coordinates in the given inputfile by a given factor, so the text in the resulting pdf is in place again.

Usage

Options:

  • -i inputfile
  • -o outputfile
  • -s shrink factor (default 2)

Example:

hocrShrink.py -i input.html -o outputOneFouth.html -s 4

or use stdin/out:

hocrShrink.py -s4 < input.html

that can be handy for hocr2pdf, that needs stdin:

hocrShrink.py -s2 < tesseractoutput.html | hocr2pdf -i shrunkBy2.tif -s -o little.pdf
hocrShrink.py -s4 < tesseractoutput.html | hocr2pdf -i shrunkBy4.tif -s -o verysmall.pdf

hocrshrink's People

Contributors

hallo-alex avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.