tj / palette

Node.js image color palette extraction with node-canvas
292 stars 24 forks source link

Handle invalid result from quantize palette call #9

Open balthazar opened 8 years ago

balthazar commented 8 years ago

Sometimes, the palette from the CMap of quantize can return false, leading to an uncaught error. This helps catching it smoothly by returning an empty array.

balthazar commented 8 years ago

After further investigations, it often happens when providing an invalid value of RGB color values. I can create another PR / update this one to prevent this by throwing an error or resetting the value to a valid one, as you prefer @tj.