dannnylo/rtesseract — pull request #6 by jimi1283 (2012-01-13 04:52:20+00:00)
Title: Added ability to read in a string blob

I've run into a situation where it's required that I create a RMagick image to do some pre-processing of an image (for instance, to increase the density) to allow for better OCR results. In order to avoid having to write a file to disk just to re-read it with RTesseract I thought it would be useful to have the ability to read in a blob created with RMagick's to_blob function.

I have not tested this fully with mini_magick (not what I use), but I stubbed that out anyway to match.

Here's my test case:

blob = Magick::Image.read("some.jpg").first.resample(600).auto_gamma_channel().white_threshold(245).quantize(256,GRAYColorspace).to_blob

test = RTesseract.new("/tmp/bar.tiff") # /tmp/bar.tiff doesn't exist
test.from_blob(blob)
print test.to_s