This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function avgColor(imageUrl) { | |
var canvas = document.createElement('canvas'); | |
var context = canvas.getContext && canvas.getContext('2d'); | |
var rgb = {r: 102, g: 102, b: 102}; // Set a base colour as a fallback for non-compliant browsers | |
var pixelInterval = 5; // Rather than inspect every single pixel in the image inspect every 5th pixel | |
var count = 0; | |
var i = -4; | |
var img = document.createElement('img'); | |
var data; | |
var length; |