I have a piece of code that extracts image data from an image and it outputs it as the 8 bit integer array in the JS console. Is there a way I could convert that to a base 64 URI the image data when I write it to a string it gives me garbled text because it is just raw bit data.
Asked
Active
Viewed 63 times
0
-
Why not get the Base64 immediately from the File object? https://stackoverflow.com/a/39440179/383904 Otherwise I suppose you could use `new Blob([arr], {type})` and `new FileReader` – Roko C. Buljan Oct 03 '22 at 12:58
-
@RokoC.Buljan I am grabbing the data directly from a png that is stored on the website which is stored as raw png data. (its wierd I know) – David C Oct 03 '22 at 13:02
-
“when I output it as a string looks like if you opened the image in notepad” This makes no sense to me, please [edit] the post to clarify. – Cris Luengo Oct 03 '22 at 13:12
-
The text is clearer now, but I still don’t understand what you want to accomplish. You want a URI, which is a direction that points at something, usually a file. You cannot have it point to data in memory, so you’ll have to save your image data to disk first. But what you wrote somehow makes me think you want to see the image in the terminal window when your program outputs it. Maybe something like ASCII art? – Cris Luengo Oct 03 '22 at 13:35
-
@CrisLuengo Im trying to convert the data to a uniform resource identifier which store base 64 data for Images/Text/Audio (Close to raw data but can be used as image input and output as well as easier and less cumbersome to store and manipulate) Also thanks for trying to help me and understand what im trying to ask! – David C Oct 03 '22 at 13:43