image_to_html

CLI tool to OCR an image and output HTML containing the image and its extracted text.

ImageToHTML

CLI tool to OCR an image and output HTML containing the image and its extracted text.

$ image-to-html hello.jpg > ~/tmp/hello.jpg.html

Output of ImageToHTML

Installation

This program must be compiled from source.

Prerequisites:

  • A working Crystal compiler is needed.
  • The tesseract binary must be available in your PATH.
  1. Clone this git repo:
$ git clone git@github.com:garethrees/image_to_html.git
  1. To build a binary:
$ make bin/image-to-html
  1. To use as a library, add the dependency to your shard.yml:
dependencies:
  image_to_html:
    github: garethrees/image_to_html
  1. Run shards install

Usage

As a binary:

# Print the HTML to stdout
$ bin/image-to-html /path/to/image.jpg

# You can redirect stdout to create a HTML file
$ bin/image-to-html /path/to/image.jpg > image.jpg.html

As a library:

# Just generate the HTML
html = ImageToHtml.run("/path/to/image.jpg")

# Or build it up yourself
html = ImageToHtml::Html.new(
  ImageToHtml::Image.new(
    Path["/path/to/image.jpg"]
  )
).to_s

Contributing

  1. Fork it (https://github.com/garethrees/image_to_html/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make sure the tests pass (make test)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Contributors

Credits

Repository

image_to_html

Owner
Statistic
  • 2
  • 1
  • 0
  • 0
  • 1
  • over 2 years ago
  • December 2, 2021
License

MIT License

Links
Synced at

Sun, 17 Nov 2024 02:03:19 GMT

Languages