Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Merging various references found here in StackOverflow (including the article above) and in other sites, I did so using javascript and JQuery:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;canvas id="myCanvas" width="400" height="400" style="border:1px solid #c3c3c3;"&gt; Your browser does not support the canvas element. &lt;/canvas&gt; &lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; window.onload = function(){ var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var img = new Image(); img.src = 'photo_apple.jpg'; context.drawImage(img, 0, 0); }; function findPos(obj){ var current_left = 0, current_top = 0; if (obj.offsetParent){ do{ current_left += obj.offsetLeft; current_top += obj.offsetTop; }while(obj = obj.offsetParent); return {x: current_left, y: current_top}; } return undefined; } function rgbToHex(r, g, b){ if (r &gt; 255 || g &gt; 255 || b &gt; 255) throw "Invalid color component"; return ((r &lt;&lt; 16) | (g &lt;&lt; 8) | b).toString(16); } $('#myCanvas').click(function(e){ var position = findPos(this); var x = e.pageX - position.x; var y = e.pageY - position.y; var coordinate = "x=" + x + ", y=" + y; var canvas = this.getContext('2d'); var p = canvas.getImageData(x, y, 1, 1).data; var hex = "#" + ("000000" + rgbToHex(p[0], p[1], p[2])).slice(-6); alert("HEX: " + hex); }); &lt;/script&gt; &lt;img src="photo_apple.jpg"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is my complete solution. Here I only used canvas and one image, but if you need to use <code>&lt;map&gt;</code> over the image, it's possible too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload