Live data from Hacker News

Show HN: An API to extract texts from images and PDF files

stamplin.com

21–30 of 33 posts

Re: Show HN: An API to extract texts from images and PDF files

#21
post #20

What's the benefit to using this over `pdftotext` and/or `pdfimages | convert | tesseract`?

we think that's easier to integrate as there is nothing to install, nothing to maintain. We are also doing some pre/post processing which allow orientation detection for example. We also think that's might be useful for mobile as they are limited in resources. Also, on a PDF, we have an hybric way to perform both to not use slow OCR methods on easy to extract text but that's still quite a young product. New advanced features are coming.

Re: Show HN: An API to extract texts from images and PDF files

#22

Why would someone want to use an API instead of a library?

some langages might not have an appropriate library, some might want to not have heavy processes on their device (mobiles). We also think that's easier to use as there is nothing to install. That mainly depends on your case.

Re: Show HN: An API to extract texts from images and PDF files

#24
post #22

Why would someone want to use an API instead of a library?

some langages might not have an appropriate library, some might want to not have heavy processes on their device (mobiles). We also think that's easier to use as there is nothing to install. That mainly depends on your case.

I agree that there might situations where it can be useful, but:

1) Mobiles have pretty good CPUs. I think uploading and waiting for response would be slower and less reliable.

2) If the mobile user doesn't have an internet connection, the app won't work.

3) As a developer, I would be dependant on an external service, that could stop working someday.

Re: Show HN: An API to extract texts from images and PDF files

#26
post #20

What's the benefit to using this over `pdftotext` and/or `pdfimages | convert | tesseract`?

The benefit is stamplin.com gets insight on what people are viewing and reading. They get to see what the user sees. They can compile a database and use or sell that information to be used for marketing purposes.

Also, it's an "API" (looks more like a url poiting to a CGI program to me, but whatever). API's are "cool" and "fun", while running local programs that you have control over is old and boring and not the future of computing.

Re: Show HN: An API to extract texts from images and PDF files

#27
I come bearing gifts, if anyone would like to host some of this themselves.

This follows the API documented by Stampin (minus the throttling errors)--it does not currently do the OCR, but as mentioned elsewhere by zdw you can probably get tesseract to get you like 80% of the way there. If you wanted to use that, you'd likely just replace the hacky `pdftotext` callout with your preferred toolchain.

You'll need Ruby, Sinatra, and the Xpdf tools, I believe.

Dual-licensed under the AGPL, BSD, and WTFPL licenses. idklol.

The code:

  require 'sinatra'
  require 'json'

  use Rack::Logger

  post '/extracttext' do

      begin
      status 204 and return unless params["file"] != nil

      type = params["type"] || "text"
      lang = params["lang"] || "en"

      tmpfilename = params["file"][:tempfile].path
      `pdftotext #{tmpfilename}`
      File.delete(tmpfilename)

      convfile = File.open("#{tmpfilename}.txt","r")
      lines = convfile.read.split("\n")
      convfile.close
      File.delete(convfile.path)

      content_type "application/json"
      {"text"=>lines}.to_json

      rescue
          status 500 and return
      end
  end
EDIT:

For God's sake run this in a jail and only on an internal network!

Re: Show HN: An API to extract texts from images and PDF files

#29
The OCR is really useless. I tested it with some reddit "advice animal" memes (because there is a need for transcriptions). You would think that text is pretty simple and easy, but the output I got was like:

    /\n\nnmrs wn\ufb02qyi mm mm\nTlIIEI\ufb02|\ufb02llllM\u2018l co

Re: Show HN: An API to extract texts from images and PDF files

#30
post #29

The OCR is really useless. I tested it with some reddit "advice animal" memes (because there is a need for transcriptions). You would think that text is pretty simple and easy, but the output I got was like: /\n\nnmrs wn\ufb02qyi mm mm\nTlIIEI\ufb02|\ufb02llllM\u2018l co

Sorry that didn't work properly for you. We are working on improving our OCR results quality. Could you please send us at info@stamplin.com the file you used to get this useless result?
Post reply on HN