Skip to content

Codre01/is-image-blurry

Repository files navigation

is-image-blurry

A lightweight TypeScript library to detect if an image is blurry using Laplacian variance analysis.

Installation

npm install is-image-blurry

Usage

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 image
  • options.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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors