
Security News
Socket Integrates With Bun 1.3’s Security Scanner API
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
blurry-check
Advanced tools
A comprehensive blur detection library for images and PDFs that works across all JavaScript frameworks
A comprehensive, framework-agnostic blur detection library for images and PDFs. Detect blurry images and low-quality scanned documents with ease across any JavaScript framework including React, Angular, Vue, Qwik, and plain JavaScript.
Test the library with your own images and PDFs in our interactive demo. Upload files to see real-time blur detection and quality analysis in action.
npm install blurry-check
Or with yarn:
yarn add blurry-check
import { BlurryCheck } from 'blurry-check';
// Create an instance
const checker = new BlurryCheck();
// Check if an image is blurry
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
if (file.type.startsWith('image/')) {
const isBlurry = await checker.isImageBlurry(file);
console.log('Image is blurry:', isBlurry);
}
if (file.type === 'application/pdf') {
const isGoodQuality = await checker.isPDFGoodQuality(file);
console.log('PDF quality is good:', isGoodQuality);
}
});
import { BlurryCheck } from 'blurry-check';
const checker = new BlurryCheck({
method: 'both', // Use both edge detection and OpenCV
edgeWidthThreshold: 0.3, // Lower = more sensitive to blur
laplacianThreshold: 150, // Higher = more sensitive to blur
debug: true // Enable debug logging
});
// Get detailed analysis
const analysis = await checker.analyzeImage(imageFile);
console.log('Blur analysis:', analysis);
/*
{
isBlurry: false,
confidence: 0.85,
method: 'both',
metrics: {
edgeAnalysis: {
width: 1920,
height: 1080,
numEdges: 1250,
avgEdgeWidth: 2.3,
avgEdgeWidthPerc: 0.12
},
laplacianVariance: 245.7
}
}
*/
Option | Type | Default | Description |
---|---|---|---|
method | 'edge' | 'laplacian' | 'both' | 'both' | Detection method to use |
edgeWidthThreshold | number | 0.3 | Threshold for edge detection (0-100) |
laplacianThreshold | number | 150 | Threshold for OpenCV Laplacian variance |
openCvUrl | string | OpenCV CDN | Custom OpenCV.js URL |
canvas | HTMLCanvasElement | auto-created | Canvas element for processing |
debug | boolean | false | Enable debug logging |
new BlurryCheck(config?: BlurDetectionConfig)
isImageBlurry(input)
Quick check if an image is blurry.
async isImageBlurry(
input: HTMLImageElement | HTMLCanvasElement | File | ImageData
): Promise<boolean>
analyzeImage(input)
Detailed image blur analysis.
async analyzeImage(
input: HTMLImageElement | HTMLCanvasElement | File | ImageData
): Promise<BlurAnalysisResult>
isPDFGoodQuality(file)
Quick PDF quality check.
async isPDFGoodQuality(file: File): Promise<boolean>
analyzePDF(file)
Detailed PDF quality analysis.
async analyzePDF(file: File): Promise<PDFAnalysisResult>
analyzeFile(file, options?)
Automatically detect file type and analyze.
async analyzeFile(
file: File,
options?: FileAnalysisOptions
): Promise<BlurAnalysisResult | PDFAnalysisResult>
For quick one-off checks without creating an instance:
import { isImageBlurry, isPDFGoodQuality, analyzeFile } from 'blurry-check';
// Quick image check
const blurry = await isImageBlurry(imageFile);
// Quick PDF check
const goodQuality = await isPDFGoodQuality(pdfFile);
// Auto-detect file type
const analysis = await analyzeFile(file);
import React, { useState } from 'react';
import { BlurryCheck } from 'blurry-check';
const ImageUploader: React.FC = () => {
const [isBlurry, setIsBlurry] = useState<boolean | null>(null);
const checker = new BlurryCheck({ method: 'both', debug: true });
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file) {
const blurry = await checker.isImageBlurry(file);
setIsBlurry(blurry);
}
};
return (
<div>
<input type="file" accept="image/*" onChange={handleFileChange} />
{isBlurry !== null && (
<p>Image is {isBlurry ? 'blurry' : 'clear'}</p>
)}
</div>
);
};
<template>
<div>
<input type="file" @change="handleFileChange" accept="image/*" />
<p v-if="result !== null">
Image is {{ result ? 'blurry' : 'clear' }}
</p>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { BlurryCheck } from 'blurry-check';
const result = ref<boolean | null>(null);
const checker = new BlurryCheck({ method: 'both' });
const handleFileChange = async (e: Event) => {
const file = (e.target as HTMLInputElement).files?.[0];
if (file) {
result.value = await checker.isImageBlurry(file);
}
};
</script>
import { Component } from '@angular/core';
import { BlurryCheck } from 'blurry-check';
@Component({
selector: 'app-image-checker',
template: `
<input type="file" (change)="onFileChange($event)" accept="image/*">
<p *ngIf="isBlurry !== null">
Image is {{ isBlurry ? 'blurry' : 'clear' }}
</p>
`
})
export class ImageCheckerComponent {
isBlurry: boolean | null = null;
private checker = new BlurryCheck({ method: 'both' });
async onFileChange(event: Event) {
const file = (event.target as HTMLInputElement).files?.[0];
if (file) {
this.isBlurry = await this.checker.isImageBlurry(file);
}
}
}
import { component$, useSignal } from '@builder.io/qwik';
import { BlurryCheck } from 'blurry-check';
export const ImageChecker = component$(() => {
const isBlurry = useSignal<boolean | null>(null);
const checker = new BlurryCheck({ method: 'both' });
return (
<div>
<input
type="file"
accept="image/*"
onChange$={async (e) => {
const file = (e.target as HTMLInputElement).files?.[0];
if (file) {
isBlurry.value = await checker.isImageBlurry(file);
}
}}
/>
{isBlurry.value !== null && (
<p>Image is {isBlurry.value ? 'blurry' : 'clear'}</p>
)}
</div>
);
});
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/blurry-check/lib/index.umd.js"></script>
</head>
<body>
<input type="file" id="fileInput" accept="image/*">
<p id="result"></p>
<script>
const checker = new BlurryCheck.default();
document.getElementById('fileInput').addEventListener('change', async (e) => {
const file = e.target.files[0];
if (file) {
const isBlurry = await checker.isImageBlurry(file);
document.getElementById('result').textContent =
`Image is ${isBlurry ? 'blurry' : 'clear'}`;
}
});
</script>
</body>
</html>
{
isBlurry: boolean; // Whether image is considered blurry
confidence: number; // Confidence score (0-1)
method: string; // Method used for detection
metrics: {
edgeAnalysis?: {
width: number; // Image width
height: number; // Image height
numEdges: number; // Number of edges detected
avgEdgeWidth: number; // Average edge width in pixels
avgEdgeWidthPerc: number; // Average edge width as percentage
};
laplacianVariance?: number; // OpenCV variance value
};
}
{
isQualityGood: boolean; // Whether PDF quality is acceptable
isScanned: boolean; // Whether PDF is image-based
pagesAnalyzed: number; // Number of pages checked
textLength: number; // Amount of extractable text
pageResults?: BlurAnalysisResult[]; // Per-page analysis results
}
'edge'
for speed, 'laplacian'
for accuracy, 'both'
for best resultsBlurryCheck
instance and reuse itOpenCV fails to load
// Use custom OpenCV URL or fallback to edge detection
const checker = new BlurryCheck({
method: 'edge', // Fallback method
openCvUrl: 'https://your-cdn.com/opencv.js'
});
Canvas errors in Node.js
# Install canvas polyfill for Node.js
npm install canvas
Large file processing
// Reduce canvas size for large images
const checker = new BlurryCheck({
canvas: createSmallCanvas() // Custom smaller canvas
});
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This package is maintained by Idenva - Advanced document processing and AI solutions.
FAQs
A comprehensive blur detection library for images and PDFs that works across all JavaScript frameworks
The npm package blurry-check receives a total of 0 weekly downloads. As such, blurry-check popularity was classified as not popular.
We found that blurry-check demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.
Security News
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.