is-image-blurry
v1.0.0
Published
A lightweight TypeScript library to detect if an image is blurry using Laplacian variance
Maintainers
Readme
is-image-blurry
A lightweight TypeScript library to detect if an image is blurry using Laplacian variance analysis.
Installation
npm install is-image-blurryUsage
import isImageBlurry from 'is-image-blurry';
// Basic usage with default threshold (400)
const isBlurry = await isImageBlurry({ dataUrl: 'data:image/jpeg;base64,...' });
// Custom threshold (lower values = more sensitive to blur)
const isBlurry = await isImageBlurry({
dataUrl: 'data:image/jpeg;base64,...',
threshold: 300
});API
isImageBlurry(options)
Returns a Promise that resolves to true if the image is detected as blurry, false otherwise.
Parameters
options.dataUrl(string): Base64 data URL of the imageoptions.threshold(number, optional): Blur detection threshold. Default: 400. Lower values make detection more sensitive.
Returns
Promise<boolean>: True if image is blurry, false otherwise
How it works
The library uses the Laplacian operator to detect edges in the image and calculates the variance of the result. Images with low variance are considered blurry as they have fewer sharp edges.
Browser Compatibility
This library requires a browser environment with Canvas API support.
License
MIT
