How to add image to steem blockchain directly

in #utopian-io7 years ago (edited)

Hi, this tutorial is english version on my polish tutorial posted before.
I was wondering is really possible to put image itself to blockchain database.

You may ask, well we can add pictures to our post on steem using steemit interface with it's own picture hosting or any other external image hosting. But in this tutorial you are going to see how to add something what is going to be permanent and once you put it to blockchain it's going to be there forever. No one will be able delete it, only you can change post with image within 7 days.

The image has to be translated from "jpg" format to text format, so we will be able to add it to our post. Obviously users using steemit interface are going to see bunch of characters, but if there is going to be a interface interpreting those charaters as pictures - well you can create blockchain based picture hosting :)

In short, what you're going to learn:

  • What is base64
  • How to convert picture to Base64 code
  • Read an image from base64 code

All you need for this tutorial are:

  • Steem account
  • Some free time
  • Internet obviously
  • Web browser

This tutorial is fairly easy to go through so it's a basic difficulty.

Ok, so what's base64?
To make it simple, let's say that it's a special encoding algorithm which get's data in bytes and converts it to a array of characters. It is really useful when we are doing some transportation actions in the Internet. We can convert simple text into base64 code, but also image to base64 code. The second example is going to be useful in this tutorial.
Example encoding of Hello steem! is SGVsbG8gc3RlZW0h.
If you want to reverse this example base64 code you can do it for example here. Simply paste SGVsbG8gc3RlZW0h and click `Decode.

Now let's head to our purpose which is to store image in steem blockchain.

First step is to find picture we want to convert and save to steem blockchain.
I'm going to put this:

image.png

First steem is to find any website or application which converts image to base64 code. I'll choose this service:

image.png

You should see "Upload file" button on website, where you choose your picture. When you finished just click "Upload".

You should see something like this:

image.png

Now, let's copy content of RAW window containing base64 code. Let's head to steem interface, where we can post a content with image code. All you need to do is to copy and paste base64 code to your post. After this step simply publish this post. I won't show you how to post something because it is trivial task.

Once you publish your image, you should see something like this:

image.png

Pretty useless, huh? Well, not true!

Now our magic happens. Let's copy whole code which we just published and copy to appropriate place which will convert base64 to image.

I'm going to choose this. It can be any other website or software. paste published base64 code and click generate image.
If you did all steps correctly, you should see something like this:

image.png

And as you can see, you can post almost any picture. Main limitation is post body length in character. Officially on steemit interface you have 64,000 character limit. What's blockchain steem limit of characters, well I don't know.

I bet, not many people was aware of this possiblity. It might be helpful when you need something what it's important to be publicly accesible and free of censorship. If someone will create spectial interface to interpret this kind of posts than you get decentralised image hosting :) Of course steem blockchain is not the best place to create mass file hosting, but if we must save something, it's great place to do it.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • Submissions presenting content creation and simple on-screen instruction will be rejected.

You can contact us on Discord.
[utopian-moderator]

Hey @portugalcoin, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.034
BTC 89422.86
ETH 3144.72
USDT 1.00
SBD 2.76