Get first pixel (0,0) of image with jQuery

117 views Asked by At

I need get only first pixels (0,0) of image with jquery (RGBA or HEX)

pls help me :D

1

There are 1 answers

0
Backs On BEST ANSWER

You have to draw the image in a canvas element. Then you can use the getImageData method to return an array containing RGBA values.

var img = new Image();
img.src = 'image.jpg';
var context = document.getElementById('canvas').getContext('2d');
context.drawImage(img, 0, 0);
data = context.getImageData(x, y, 1, 1).data;