In my test project I want to convert my png image to Uint8Array. I found some solution
pngFileToUint8Array(pngPath: string): Promise<Uint8Array> {
const png: File = new File([pngImage], pngPath, { type: 'image/png' });
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
const resultArrayBuffer = event.target?.result as ArrayBuffer;
const uint8Array = new Uint8Array(resultArrayBuffer);
resolve(uint8Array);
};
reader.onerror = (error) => {
reject(error);
};
reader.readAsArrayBuffer(png);
});
}
And my problem is how to declare png file to File Object ;/ I have png file on my disk.
Thanks for any tips 🙂