2021-01-29

How can I read metadata of PNG in react

There is json data in png, and I want to read that metadata in the PNG file. I am using reactjs. After upload an image file, and then any idea?

import React, { useState } from 'react'
import {Typography, Button, Form, Input} from 'antd';
import Axios from 'axios';

function test() { 
    const [imgBase64, setImgBase64] = useState(""); 
    const [imgages, setImages] = useState([]);      
    
    const fileupload = (event) => {
      const readit = new FileReader();
  
      reader.onloadend = () => {
        const base64 = readit.result;
        if (base64) {
          setImgBase64(base64.toString()); 
        }
      }
      if (event.target.files[0]) {
        readit.readAsDataURL(event.target.files[0]); 
        setImages(event.target.files[0]); 
        console.log(event.target.files[0]);
      }
    }
    
    return (
        <div style=>
        </div>
          <input type="file" onChange={fileupload}/>
        </div>
      </div>
    );
  }

export default test


from Recent Questions - Stack Overflow https://ift.tt/2MBJoQZ
https://ift.tt/eA8V8J

No comments:

Post a Comment