Будет работать только если все файлы на одном хостинге лежат и запуск идет с родного домена..
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8" />
<meta name="author" content="Script Tutorials" />
<title>HTML5 canvas - Image color picker | Script Tutorials</title>
<link href="https://www.script-tutorials.com/demos/158/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://www.script-tutorials.com/demos/158/js/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
var canvas;
var ctx;
var images = [ // predefined array of used images
'https://www.script-tutorials.com/demos/158/images/pic1.jpg',
'https://www.script-tutorials.com/demos/158/images/pic2.jpg',
'https://www.script-tutorials.com/demos/158/images/pic3.jpg',
'https://www.script-tutorials.com/demos/158/images/pic4.jpg',
'https://www.script-tutorials.com/demos/158/images/pic5.jpg',
'https://www.script-tutorials.com/demos/158/images/pic6.jpg',
'https://www.script-tutorials.com/demos/158/images/pic7.jpg',
'https://www.script-tutorials.com/demos/158/images/pic8.jpg',
'https://www.script-tutorials.com/demos/158/images/pic9.jpg',
'https://www.script-tutorials.com/demos/158/images/pic10.jpg'
];
var iActiveImage = 0;
$(function(){
// drawing active image
var image = new Image();
image.onload = function () {
ctx.drawImage(image, 0, 0, image.width, image.height); // draw the image on the canvas
}
image.src = images[iActiveImage];
// creating canvas object
canvas = document.getElementById('panel');
ctx = canvas.getContext('2d');
$('#panel').mousemove(function(e) { // mouse move handler
var canvasOffset = $(canvas).offset();
var canvasX = Math.floor(e.pageX - canvasOffset.left);
var canvasY = Math.floor(e.pageY - canvasOffset.top);
var imageData = ctx.getImageData(canvasX, canvasY, 1, 1);
var pixel = imageData.data;
var pixelColor = "rgba("+pixel[0]+", "+pixel[1]+", "+pixel[2]+", "+pixel[3]+")";
$('#preview').css('backgroundColor', pixelColor);
});
$('#panel').click(function(e) { // mouse click handler
var canvasOffset = $(canvas).offset();
var canvasX = Math.floor(e.pageX - canvasOffset.left);
var canvasY = Math.floor(e.pageY - canvasOffset.top);
var imageData = ctx.getImageData(canvasX, canvasY, 1, 1);
var pixel = imageData.data;
$('#rVal').val(pixel[0]);
$('#gVal').val(pixel[1]);
$('#bVal').val(pixel[2]);
$('#rgbVal').val(pixel[0]+','+pixel[1]+','+pixel[2]);
$('#rgbaVal').val(pixel[0]+','+pixel[1]+','+pixel[2]+','+pixel[3]);
var dColor = pixel[2] + 256 * pixel[1] + 65536 * pixel[0];
$('#hexVal').val( '#' + dColor.toString(16) );
});
$('#swImage').click(function(e) { // switching images
iActiveImage++;
if (iActiveImage >= 10) iActiveImage = 0;
image.src = images[iActiveImage];
});
});
</script>
</head>
<body>
<div class="container">
<div class="column1">
<canvas id="panel" width="500" height="333"></canvas>
</div>
<div class="column2">
<div><input type="button" value=" Следующая картинка " id="swImage" /></div>
<div>Preview:</div>
<div id="preview"></div>
<div>Color:</div>
<div>R: <input type="text" id="rVal" /></div>
<div>G: <input type="text" id="gVal" /></div>
<div>B: <input type="text" id="bVal" /></div>
<div>RGB: <input type="text" id="rgbVal" /></div>
<div>RGBA: <input type="text" id="rgbaVal" /></div>
<div>HEX: <input type="text" id="hexVal" /></div>
<hr />
</div>
<div style="clear:both;"></div>
</div>
</body>
</html>