-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Calculate and expose a sharpness value in stats #2251
Description
Big fan of your work on sharp and thanks for doing what you do and working on it! I've been using it a lot along side Gatsby and Electron projects.
What are you trying to achieve?
Have a sharpness value in the stats object, in order to make assumptions about blurry images.
Have you searched for similar feature requests?
I have. Found nothing.
What would you expect the API to look like?
const stats = await sharp(image)
.stats()
.then(stats => stats)
console.log('Sharpness: ', stats.sharpness)What alternatives have you considered?
Calculating myself (or using OpenCV) by converting a single channel to grayscale and calculating a Laplacian. (There are some resources online on how to do this, here's one for context)
Is there a sample image that helps explain?
Here is some image from Unsplash:

Photo by Sergei Akulich on Unsplash
And here is the same image blurred a bit manually in GIMP:

Basically I think it would be a great feature for sharp to have, since it already has low level access to raw image data. I'm not completely sure how hard it would be to implement, so figured I'd open a ticket to see how you feel about it, as well any potential users of the feature.