mani-screensense
v1.2.0
Published
Intelligent screen text extraction library with OCR, hotkeys, batch processing, and AI capabilities
Downloads
205
Maintainers
Readme
mani-screensense 👁️
Intelligent Screen Text Extraction Library
A powerful Node.js library for OCR, screen capture, hotkeys, batch processing, and more. Extract text from images or your screen with just one line of code!
⚡ Installation
npm install mani-screensense🚀 Quick Start (One-Liners!)
const { screenToText, imageToText, screenshot } = require('mani-screensense');
// 📸 Capture screen → text
const text = await screenToText();
// 🖼️ Image file → text
const text = await imageToText('./document.png');
// 📷 Save screenshot
await screenshot('./screen.png');🖥️ CLI Tool
npm install -g mani-screensense
# Commands
screensense capture # Screen → text
screensense read ./doc.png # Image → text
screensense screenshot # Save screenshot
screensense capture --copy # Copy to clipboard
screensense read ./jp.png -l jpn # Japanese OCR🔑 Hotkey Support
Register keyboard shortcuts to trigger actions:
const { createHotkeyManager } = require('mani-screensense');
const hotkeys = createHotkeyManager({
capture: 'ctrl+shift+s', // Capture screen
region: 'ctrl+shift+r', // Capture region
clipboard: 'ctrl+shift+c' // Read clipboard
});
hotkeys.on('registered', (key) => {
console.log(`Hotkey registered: ${key}`);
});
hotkeys.startListening();📁 Batch Processing
Process multiple images at once:
const { batchProcess, batchProcessFolder } = require('mani-screensense');
// Process multiple files
const results = await batchProcess([
'./doc1.png',
'./doc2.png',
'./doc3.png'
], {
language: 'eng',
onProgress: (current, total, file) => {
console.log(`Processing ${current}/${total}: ${file}`);
}
});
// Or process entire folder
const results = await batchProcessFolder('./documents', {
format: 'json',
outputPath: './results.json'
});👁️ File Watcher
Auto-process new images in a folder:
const { watchFolder } = require('mani-screensense');
const watcher = await watchFolder('./inbox', (event) => {
if (event.type === 'added') {
console.log(`New file: ${event.file}`);
console.log(`Text: ${event.result.text}`);
}
});
// Stop watching
await watcher.stop();🖼️ Image Preprocessing
Enhance images for better OCR:
const { preprocessImage, autoEnhance, presets } = require('mani-screensense');
// Auto-enhance (recommended)
const enhanced = await autoEnhance('./blurry.png');
// Manual options
const processed = await preprocessImage('./image.png', {
grayscale: true,
sharpen: true,
contrast: 30,
denoise: true
});
// Use presets
const docImage = await presets.document('./scan.png');
const photoText = await presets.photo('./photo.png');
const lowQuality = await presets.lowQuality('./bad.png');📤 Export Formats
Convert results to different formats:
const { analyzeImage, toJSON, toCSV, toHTML, toMarkdown } = require('mani-screensense');
const result = await analyzeImage('./doc.png');
// Different formats
const json = toJSON(result, { includeConfidence: true });
const csv = toCSV(result); // Words with positions
const html = toHTML(result); // Styled HTML page
const md = toMarkdown(result); // Markdown format🛠️ Utility Functions
const {
extractEmails,
extractUrls,
extractDates,
extractPhoneNumbers,
detectLanguage,
copyToClipboard,
detectCode
} = require('mani-screensense');
const text = "Contact: [email protected], visit https://example.com";
extractEmails(text); // ['[email protected]']
extractUrls(text); // ['https://example.com']
extractDates(text); // Finds dates in various formats
detectLanguage(text); // 'eng'
detectCode(text); // true if contains code🌍 Supported Languages
| Code | Language | Code | Language |
|------|----------|------|----------|
| eng | English | jpn | Japanese |
| spa | Spanish | kor | Korean |
| fra | French | chi_sim | Chinese |
| deu | German | ara | Arabic |
| ita | Italian | hin | Hindi |
| por | Portuguese | rus | Russian |
📚 All Features
| Feature | Description |
|---------|-------------|
| One-liners | screenToText(), imageToText(), screenshot() |
| CLI Tool | screensense capture, screensense read |
| Hotkeys | Register keyboard shortcuts |
| Batch Processing | Process multiple images |
| File Watcher | Auto-process new images |
| Preprocessing | Enhance images for better OCR |
| Export Formats | JSON, CSV, HTML, Markdown, XML |
| Utilities | Extract emails, URLs, dates, code detection |
📄 License
MIT © Mani Reddy
