Uploading image stored under "data:image/png;base64" in browser to IPFS

I converted data from HTML page by converting it to a canvas using “html2canvas” and also converted the canvas to url using “toDataURL” function which left me with a data url of the image.

And now i am trying to upload this “data:image/png;base64” which i got from “toDataURL” to IPFS. Is it possible?

I am actually trying to skip downloading the canvas as image and then reuploading to IPFS by directly uploading the canvas data to IPFS.

Image Url Sample

it should be possible to upload that data to IPFS or in other location, but I don’t know exactly how you are going to display it, as I think that you will have to download that data in order to display it.

The data from “data:image/png;base64” can be viewed using img tag.
So I think I can skip uploading the image to IPFS and instead i can give the image url as “data:image/png;base64,…” while minting, but the url length will be crazy huge.

<!DOCTYPE html>
<html>
<body>

<h2>HTML Image</h2>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAAAXNSR0IArs4c6QAAG3NJREFUeF7t2FGOHMkNRVFpG137X5rWMQYG/pANj8Wu7owgH4+/U53Bw0hc1/z8+Pj464f/ESBAgAABAqMFfgr66P05PAECBAgQ+FtA0F0EAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAgECAgKAHLNEIBAgQIEBA0N0BAgQIECAQICDoAUs0AgECBAgQEHR3gAABAgQIBAgIesASjUCAAAECBATdHSBAgAABAgECgh6wRCMQIECAAAFBdwcIECBAg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q6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAg8JvAif/T8Hq9IswFPWKNhiBAgECmgKDX9yrodStPEiBAgMBhAUGvgwt63cqTBAgQIHBYQNDr4IJet/IkAQIECBwWEPQ6uKDXrTxJgAABAocFBL0OLuh1K08SIECAwGEBQa+DC3rdypMECBAgcFhA0Ovggl638iQBAgQIHBYQ9Dq4oNetPEmAAAEChwUEvQ4u6HUrTxIgQIDAYQFBr4MLet3KkwQIECBwWEDQ6+CCXrfyJAECBAgcFhD0Orig1608SYAAAQKHBQS9Di7odStPEiBAgMBhAUGvgwt63cqTBAgQIHBYQNDr4IJet/IkAQIECBwWEPQ6uKDXrTxJgAABAocFBL0OLuh1K08SIECAwGEBQa+DC3rdypMECBAgcFhA0Ovggl638iQBAgQIHBYQ9Dq4oNetPEmAAAEChwUEvQ4u6HUrTxIgQIDAYQFBr4MLet3KkwQIECBwWEDQ6+CCXrfyJAECBAgcFhD0Orig1608SYAAAQK/CYhtr+sg6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBAYIyDovVYl6L324TQECBD4FgG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AgXEDQwxdsPAIECBDYISDoO/ZsSgIECBAIFxD08AUbjwABAgR2CAj6jj2bkgABAgTCBQQ9fMHGI0CAAIEdAoK+Y8+mJECAAIFwAUEPX7DxCBAgQGCHgKDv2LMpCRAgQCBcQNDDF2w8AgQIENghIOg79mxKAgQIEAgXEPTwBRuPAAECBHYICPqOPZuSAAECBMIFBD18wcYjQIAAgR0Cgr5jz6YkQIAAgXABQQ9fsPEIECBAYIeAoO/YsykJECBAIFxA0MMXbDwCBAgQ2CEg6Dv2bEoCBAgQCBcQ9PAFG48AAQIEdggI+o49m5IAAQIEwgUEPXzBxiNAgACBHQKCvmPPpiRAgACBcAFBD1+w8QgQIEBgh4Cg79izKQkQIEAgXEDQwxdsPAIECBDYISDoO/ZsSgIECBAIFxD08AUbjwABAgR2CAj6jj2bkgABAgTCBQQ9fMHGI0CAAIEdAoK+Y8+mJECAAIFwAUEPX7DxCBAgQGCHgKDv2LMpCRAgQCBcQNDDF2w8AgQIENghIOg79mxKAgQIEAgXEPTwBRuPAAECBHYICPqOPZuSAAECBMIFBD18wcYjQIAAgR0Cgr5jz6YkQIAAgXABQQ9fsPEIECBAYIeAoO/YsykJECBAIFxA0MMXbDwCBAgQ2CEg6Dv2bEoCBAgQCBcQ9PAFG48AAQIEdggI+o49m5IAAQIEwgUEPXzBxiNAgACBHQKCvmPPpiRAgACBcAFBD1+w8QgQIEBgh4Cg79izKQkQIEAgXEDQwxdsPAIECBDYIfAv8tHxs0oqt5wAAAAASUVORK5CYII=" width="100" height="100">

</body>
</html>


you want to save that image data in a smart contract at mint time?

Yes
:sweat_smile: Hoping it is possible

hoping you are using a chain with small gas fees

1 Like