jariz / vibrant.js

Extract prominent colors from an image. JS port of Android's Palette.

Home Page:http://jariz.github.io/vibrant.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property map of undefined

randohinn opened this issue · comments

The current Vibrant release gives an error like this.

Vibrant.js:651 Uncaught (in promise) TypeError: Cannot read property 'map' of undefined
    at new Vibrant (Vibrant.js:651)
    at workList.js:89
    at Array.forEach (<anonymous>)
    at workList.js:86
    at <anonymous>

Where the code calling Vibrant is

const image = new Image(200, 200);
            image.src = item.fields.image.fields.file.url;
            const vibrant = new Vibrant(image);
            const swatches = vibrant.swatches();
            alert(swatches[0].getHex());

I get the same error in Chrome Version 59.0.3071.115 (Official Build) (32-bit) on Win7. And since Chrome just updated itself when I opened Help>About, it also doesn't work in Version 60.0.3112.90 (Official Build) (32-bit)

I have the same problem – bump.

commented

You need to wait for the image to load before passing it onto Vibrant...
See the example code at https://jariz.github.io/vibrant.js/