1.1. Get image data
In this example we get data from image. The image looks like this (enlarged version):
This image is a series of 16 pixels of different colors and transparency. If you look at the extracted data, it’s just a sequence of numbers in which pixel display parameters are encoded. Each pixel is drawn by four parameters: red, green, blue, alpha.
import React from 'react'; import ReactDOM from 'react-dom'; import ImageParser from 'react-image-parser'; import demoImg from './path/to/demo/img.png'; const onImageParsed = ({ data }) => console.log(data); ReactDOM.render( <ImageParser img={demoImg} onImageParsed={onImageParsed} />, document.querySelector('.demoContainer') );