'Generate blurDataURL from nextjs itself without third party api

Nextjs allows us to use placeholder="blur" for the images that we statically import first.

For other images, we can specify a blurDataURL, however this needs generating the blurDataURL for each image on the fly.

I have failed to find a way to generate that blurDataURL in nextjs itself instead of going for third party api's that provide that.

So my queries are:

  1. How can we generate blurDataURL for dynamic images from within nextjs? (by using some library?)

  2. How can we make nextjs just use placeholder="blur" for non statically imported images but coming from the same project folders?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source