Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,90 @@ src/
## 📄 License

GNU General Public License v3.0

## 📖 Real-World Recipes

### 🛠️ CLI Power Usage

#### 1. Batch Process a Directory
The CLI processes one file at a time. Use a shell loop to process entire folders:
```bash
# Process all JPGs in 'input' dir and save to 'output' dir
mkdir -p output
for f in input/*.jpg; do
npm run cli -- "$f" -o "output/$(basename "$f")"
done
```

#### 2. Strict Redaction for Finance/Invoices
Enable strict blocking for sensitive documents:
```bash
npm run cli -- invoice.jpg \
--block-words "Confidential,SSN,Account" \
--custom-regex "(?i)account\s*#?\s*\d+" \
--no-ips # Disable IP scanner if irrelevant to boost speed
```

#### 3. Allowlist for Internal Docs
Prevent redaction of known internal terms or headers:
```bash
npm run cli -- internal-doc.jpg \
--allowlist "CorpCorp,192.168.1.1,ProjectX"
```

---

### 🐳 Docker API Examples

The Docker API runs on port 3000 by default. It currently uses standard detection settings (Emails, IPs, Keys, PII).

#### 1. Quick Test via Curl
```bash
curl -X POST http://localhost:3000/redact \
-F "image=@/path/to/doc.jpg" \
-o redacted.png
```
*Check the `X-Redacted-Stats` header in the response for detection counts.*

#### 2. Python Integration
Process images programmatically in your Python apps:

```python
import requests

url = 'http://localhost:3000/redact'
files = {'image': open('contract.jpg', 'rb')}

response = requests.post(url, files=files)

if response.status_code == 200:
with open('redacted_contract.png', 'wb') as f:
f.write(response.content)
print("Stats:", response.headers.get('X-Redacted-Stats'))
else:
print("Error:", response.text)
```

#### 3. Node.js Integration (Native Fetch)
Requires Node.js 18+. No extra libraries needed!

```javascript
import fs from 'fs';

const fileBuffer = fs.readFileSync('id_card.jpg');
const blob = new Blob([fileBuffer], { type: 'image/jpeg' });

const formData = new FormData();
formData.append('image', blob, 'id_card.jpg');

const response = await fetch('http://localhost:3000/redact', {
method: 'POST',
body: formData
});

if (response.ok) {
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('redacted_id.png', buffer);
console.log('Stats:', response.headers.get('x-redacted-stats'));
}
```