react-color-extractor
react-color-extractor copied to clipboard
Cannot load buffer as an image in browser
I'm using image generated on the fly, and it doesn't work. Is there a solution ?
const logo = "http://www.edgebase.com/companies/amazon/logo?width=80&height=80"
<ColorExtractor src={logo} getColors={colors => console.log(colors)} onError={error => console.log(error)} />
Cannot load buffer as an image in browser
at BrowserImage../node_modules/node-vibrant/lib/image/browser.js.BrowserImage.load (browser.js:64)
at ColorExtractor._this.useDefaultImageClass (react-color-extractor.es.js:74)
at react-color-extractor.es.js:67
```
Hey,
Looking at that error message, it seems like you are passing an image array buffer to the src prop. To render this image and extract colors from it, you might wanna convert this buffer to output base64 image.
The code for this conversion could look something like this -
function(buffer) {
const bytes = new Uint8Array(buffer);
const image = document.getElementById('image');
image.src = 'data:image/png;base64,'+encode(bytes);
};
Let me know if this works 👍
Hey,
Looking at that error message, it seems like you are passing an image array buffer to the
srcprop. To render this image and extract colors from it, you might wanna convert this buffer to outputbase64image.The code for this conversion could look something like this -
function(buffer) { const bytes = new Uint8Array(buffer); const image = document.getElementById('image'); image.src = 'data:image/png;base64,'+encode(bytes); };Let me know if this works 👍
what is encode? i tried this but its not working