Sha256: 2324e4c52eb58f9305ab3784e90df77646b85d6eb2d978cb60ab4c23127a3b38
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'ocr_space/file_post' module OcrSpace module Convert def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil, clean_result: false) if file @files = File.new(file) @data = OcrSpace::FilePost.post('/parse/image', body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, file: @files }) @data = @data.parsed_response['ParsedResults'] clean_result == true ? @data[0]['ParsedText'].delete("\n").delete("\r").strip : @data = @data.parsed_response['ParsedResults'] elsif url @data = HTTParty.post('https://api.ocr.space/parse/image', body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, url: url }) @data = @data.parsed_response['ParsedResults'] clean_result == true ? @data[0]['ParsedText'].delete("\n").delete("\r").strip : @data = @data.parsed_response['ParsedResults'] else "You need to Pass either file or url." end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ocr_space-2.2 | lib/ocr_space/convert.rb |