PNG Encoder Data Compression txt ascii to png txt or html encoded into pnt png decoded back to txt html function createImage str let canvas document createElement canvas let ctx canvas getContext 2d canvas width 512 canvas height 512 var image ctx getImageData 0 0 canvas width canvas height let img image data let n 0 for let i 0 l image data length i l i 4 let c str charCodeAt i n 32 c c 32 img i 0 c img i 1 c img i 2 c img i 3 255 n 3 ctx fillRect 0 0 canvas width canvas height ctx putImageData image 0 0 return canvas toDataURL image png return canvas toDataURL image png replace image png image octet stream Convert image to octet stream Just a download really data image png base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNby blAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC async function decodeImage imgsr let baseImage document createElement img baseImage src imgsr console log imgsr new String imgsr substr 0 30 await baseImage decode let canvas document createElement canvas canvas width 512 canvas height 512 let ctx canvas getContext 2d ctx drawImage baseImage 0 0 var image ctx getImageData 0 0 canvas width canvas height var img image data var n 0 var res for i 0 l image data length i l i 4 let c img i 0 res String fromCharCode c 32 n 3 return res encode let encimg createImage once upon a time decode let txt await decodeImage encimg console log txt txt
ase64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNby blAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC async function decodeImage imgsr let baseImage document createElement img baseImage src imgsr console log imgsr new String imgsr substr 0 30 await baseImage decode let canvas document createElement canvas canvas width 512 canvas height 512 let ctx canvas getContext 2d ctx drawImage baseImage 0 0 var image ctx getImageData 0 0 canvas width canvas height var img image data var n 0 var res for i 0 l image data length i l i 4 let c img i 0 res String fromCharCode c 32 n 3 return res encode let encimg createImage once upon a time decode let txt await decodeImage encimg console log txt txt