Is it possible to determine if a given image is grayscale or color using JavaScript?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to get the background from multiple images by
- void before promise syntax
draw image to canvas
loop through image data
test for each pixel if red-cahnnel == green-channel == blue-channel (all color-channels have the same value)
if true for all pixels it is grayscale, if you hit the first pixel that does not meat the condition you can stop and it is color.
Take a look at http://www.pixastic.com/lib/docs/actions/colorhistogram/
This will easily provide the data you need to determine this.