From b416c813415142b7e4314b8aa1f8926228817881 Mon Sep 17 00:00:00 2001 From: qvrb Date: Tue, 21 Apr 2020 15:23:34 +0100 Subject: [PATCH 1/2] Update convert.rb to add in additional options provided by ocr.space --- lib/ocr_space/convert.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/ocr_space/convert.rb b/lib/ocr_space/convert.rb index 5a79bc2..45dd56f 100644 --- a/lib/ocr_space/convert.rb +++ b/lib/ocr_space/convert.rb @@ -1,13 +1,21 @@ require 'ocr_space/file_post' module OcrSpace module Convert - def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil) + def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil, file_type: nil, OCREngine: 1, isTable: false,detectOrientation: false, isCreateSearchablePdf: false,isSearchablePdfHideTextLayer: false, scale: false) + if file @files = File.new(file) @data = OcrSpace::FilePost.post('/parse/image', body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, + file_type: file_type, + OCREngine: OCREngine, + isTable: isTable, + detectOrientation: detectOrientation, + isCreateSearchablePdf: isCreateSearchablePdf, + isSearchablePdfHideTextLayer: isSearchablePdfHideTextLayer, + scale: scale, file: @files }) @data = @data.parsed_response['ParsedResults'] elsif url @@ -15,6 +23,13 @@ def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: n body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, + file_type: file_type, + OCREngine: OCREngine, + isTable: isTable, + detectOrientation: detectOrientation, + isCreateSearchablePdf: isCreateSearchablePdf, + isSearchablePdfHideTextLayer: isSearchablePdfHideTextLayer, + scale: scale, url: url }) @data = @data.parsed_response['ParsedResults'] else @@ -29,6 +44,10 @@ def clean_convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, f body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, + file_type: file_type, + OCREngine: OCREngine, + detectOrientation: detectOrientation, + scale: scale, file: @files }) @data = @data.parsed_response['ParsedResults'][0]["ParsedText"].gsub(/\r|\n/, "") elsif url @@ -36,6 +55,10 @@ def clean_convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, f body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, + file_type: file_type, + OCREngine: OCREngine, + detectOrientation: detectOrientation, + scale: scale, url: url }) @data = @data.parsed_response['ParsedResults'][0]["ParsedText"].gsub(/\r|\n/, "") else From 69b15b6983ede7c7b6add69bbbe5a77fe99a4155 Mon Sep 17 00:00:00 2001 From: qvrb Date: Wed, 22 Apr 2020 10:26:08 +0100 Subject: [PATCH 2/2] Update convert.rb --- lib/ocr_space/convert.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ocr_space/convert.rb b/lib/ocr_space/convert.rb index 45dd56f..382303f 100644 --- a/lib/ocr_space/convert.rb +++ b/lib/ocr_space/convert.rb @@ -1,7 +1,7 @@ require 'ocr_space/file_post' module OcrSpace module Convert - def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil, file_type: nil, OCREngine: 1, isTable: false,detectOrientation: false, isCreateSearchablePdf: false,isSearchablePdfHideTextLayer: false, scale: false) + def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil, file_type: nil, oCREngine: 1, isTable: false,detectOrientation: false, isCreateSearchablePdf: false,isSearchablePdfHideTextLayer: false, scale: false) if file @files = File.new(file) @@ -10,7 +10,7 @@ def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: n language: language, isOverlayRequired: isOverlayRequired, file_type: file_type, - OCREngine: OCREngine, + OCREngine: oCREngine, isTable: isTable, detectOrientation: detectOrientation, isCreateSearchablePdf: isCreateSearchablePdf, @@ -24,7 +24,7 @@ def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: n language: language, isOverlayRequired: isOverlayRequired, file_type: file_type, - OCREngine: OCREngine, + OCREngine: oCREngine, isTable: isTable, detectOrientation: detectOrientation, isCreateSearchablePdf: isCreateSearchablePdf,