electron-ocr
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -8,7 +8,8 @@ const electron = require('electron'); | ||
var mainWindow = null; | ||
const OCRAD = require('./ocrad.js'); | ||
app.on('ready', function () { | ||
console.log('suh dude'); | ||
mainWindow = new BrowserWindow() | ||
mainWindow = new BrowserWindow({ | ||
defaultFontFamily: "menu" | ||
}) | ||
mainWindow.loadURL('file://' + __dirname + '/index.html'); | ||
@@ -28,7 +29,2 @@ mainWindow.on('closed',function(){ | ||
// const convertText = function () { | ||
// }; | ||
// SAVE FILE | ||
const saveFile = function (content) { | ||
@@ -42,5 +38,3 @@ var fileName = dialog.showSaveDialog(mainWindow, { | ||
}); | ||
if (!fileName) { return; } | ||
fs.writeFileSync(fileName, content); | ||
@@ -51,2 +45,1 @@ }; | ||
exports.saveFile = saveFile; | ||
// exports.convertText = convertText; |
const electron = require('electron'); | ||
const ipc = electron.ipcRenderer; | ||
const $ = require('jquery'); | ||
const $imageView = $('.imageView'); | ||
const $translatedTextView = $('.translatedText'); | ||
const $openFileButton = $('#open-file'); | ||
const $saveFileButton = $('#save-file'); | ||
const $readImageButton = $('#read-file'); | ||
const remote = electron.remote; | ||
const mainProcess = remote.require('./main'); | ||
const output = document.getElementById('output'); | ||
const canvas = document.querySelector('.imageView'); | ||
const OCRAD = require('ocrad.js'); | ||
const canvas = document.createElement('canvas'); | ||
const context = canvas.getContext('2d'); | ||
const img = new Image(); | ||
ipc.on('file-opened', function (event, filePath) { | ||
var img = new Image(); | ||
const OCRAD = require('ocrad.js'); | ||
img.onload = function (event) { | ||
var imagePic = context.drawImage(event.target, 10, 10, event.target.width, event.target.height); | ||
} | ||
img.src = "file://" + filePath; | ||
getImageDataFromPath(filePath, (data) => console.log(data)); | ||
}); | ||
@@ -29,11 +23,2 @@ | ||
$readImageButton.on('click', function(){ | ||
var canvas = document.getElementById("canvas"); | ||
var ctx = canvas.getContext('2d'); | ||
var image = ctx.getImageData(10,10,750,80); | ||
var parsedText = OCRAD(image); | ||
console.log(parsedText) | ||
output.innerHTML = parsedText; | ||
}) | ||
$saveFileButton.on('click', function(){ | ||
@@ -43,1 +28,16 @@ var string = $translatedTextView.val(); | ||
}); | ||
function getImageDataFromPath(filePath, callback) { | ||
img.onload = function () { | ||
if (typeof callback === 'function') { | ||
canvas.width = img.width; | ||
canvas.height = img.height; | ||
context.drawImage(img, 0, 0); | ||
var imageData = context.getImageData(0, 0, img.width, img.height); | ||
var parsedText = OCRAD(imageData); | ||
output.innerHTML = parsedText; | ||
callback(imageData, output); | ||
} | ||
} | ||
img.src = 'file://' + filePath; | ||
}; |
{ | ||
"name": "electron-ocr", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "Optical Character Recognition module for Electron Applications ", | ||
@@ -8,3 +8,3 @@ "main": "lib/main.js", | ||
"start": "electron .", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha" | ||
}, | ||
@@ -11,0 +11,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1
4
1047242
7
4157