B
B
barkalov2012-11-19 15:05:39
JavaScript
barkalov, 2012-11-19 15:05:39

Jpeg, PNG, GIF -> pixel data array. How to get an array from an image on the client?

Hello!
Tell me how you can decode Jpeg, PNG and GIF into an array of colors?
And how to load an image into the browser not by URL, but from the client machine, through the File Open Dialog. No flash and no server.

What browsers support?

I would be grateful for any information.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Tyslyatsky, 2012-11-19
@barkalov

We put input type="file", through which we get the path to the file (or you can look towards fileapi ).
Using canvas you can load an image, get the height and width, and get the color of a particular pixel via context.getImageData(see stackoverflow.com/questions/6735470/get-pixel-color-from-canvas-on-mouseover ).

K
KoXGen, 2012-11-19
@KoXGen

Try: http://raphaeljs.com/

M
melo, 2012-11-19
@melo

Alternatively: http://paperjs.org/ .
Here is a drag & drop example: http://paperjs.org/examples/q-bertify/ . The authors write that it works in Webkit, Firefox, Chrome and IE 10.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question