Gives you a gradient based on the colors of an image. (browser only for now)
The function returns a promise with the data URI of the gradient image.
Note: Gradients may slightly differ from browser to browser.
<script src="https://cdn.jsdelivr.net/npm/give-me-a-gradient"></script>
<script>
renderGradient({
imagePath: 'https://picsum.photos/id/1050/400/300',
height: 480,
width: 640
})
.then((imageURI) => {
document.body.innerHTML += `<img src='${imageURI}' />`
})
</script>
npm install give-me-a-gradient
const renderGradient = require('give-me-a-gradient')
renderGradient({
imagePath: 'https://picsum.photos/id/1050/400/300',
height: 480,
width: 640
})
.then((imageURI) => {
document.body.innerHTML += `<img src='${imageURI}' />`
})
import renderGradient from 'give-me-a-gradient'
renderGradient({
imagePath: 'https://picsum.photos/id/1050/400/300',
height: 480,
width: 640
})
.then((imageURI) => {
document.body.innerHTML += `<img src='${imageURI}' />`
})
renderGradient must be passed with options.
URL of the image you want to make a gradient out of.
Height of the desired gradient image.
Width of the desired gradient image.
Quality of palette result.
- returns promise resolving with the data URI of the image
$ npm run build
$ npm run test