0

I have an image in base64 notation. Which I can convert into an array

var byteCharacters =  atob(base64);
var byteNumbers = new Array(byteCharacters.length);

for (var i = 0; i < byteCharacters.length; i++) {
    byteNumbers[i] = byteCharacters.charCodeAt(i);
}

Copied the code from here. When I output the array I see

[ 137,
  80,
  78,
  71,
  13,
  10,
  26,
  10,
  0,
  0,
  0,
  13,
  73,
  72,
  68,
  82,
  ...

What are these numbers, is it RGB colors ? Like

byteNumbers[0] --> Red
byteNumbers[1] --> Green
byteNumbers[2] --> Blue
byteNumbers[3] --> Red

But how do I get info about rows/columns ? Any help would be appreciated!

Community
  • 1
  • 1
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333

1 Answers1

3

Those numbers are the individual bytes of the raw image data (since you're talking about what you have after passing it through atob). Their meaning will depend on what kind of image it is — JPEG, GIF, BMP, TIFF, etc.

How you decode the byte stream to determine image dimensions, colors of individual pixels, etc. is very different from format to format.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Thnx. its a screenshot from within a selenium webdriver. I think it is png, because I can save it as `out.png` :) Is there a way to get the pixels/colors ? – Jeanluca Scaljeri Feb 13 '16 at 14:38