Steemit Images under 1mb could be stored on the Blockchain using Base64!

in #steemit-images8 years ago (edited)

One of the biggest issues with Steemit is that it has to rely on outside resources to host images that are held within its posts. Why this is a problem is because its not decentralized, and that's what were all about here.

We essentially rely on these outside sources for a majority of the content on steemit (that being images). I personal run one of these resources http://steemimg.com and after getting into quite a long debate / discussion on the reliability of individuals and how if these resources "pulled the plug" we would be fuc*ed! I put everything down and started to look into how we could get these images on the Blockchain.

What I came to is Base64. But is this the answer? When should we use it and when we shouldn't we?

OK, for those who don't know what Base64 image encoding is...

The particular set of 64 characters chosen to represent the 64 place-values for the base varies between implementations. The general strategy is to choose 64 characters that are both members of a subset common to most encodings, and also printable.

Essentially is a really long string of characters that all modern browsers can decode and rearrange back into the image that you originally encoded.

Here an example

(which is the image I created in hopes that I would have actually been able to accomplish this task without the help of the steemit developers)

Looks like this in Base64

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QCqRXhpZgA ATU0AKgAAAAgABgESAAMAAAABAAEAAAEaAAUAAAABAAAAVgEbAAUAAAAB
AAAAXgEoAAMAAAABAAIAAAExAAIAAAARAAAAZodpAAQAAAABAAAAeAAAAA
AAAABIAAAAAQAAAEgAAAABQWRvYmUgSW1hZ2VSZWFkeQAAAA...

Ok for those who know how long these can get that's about 4% of the total length .. YIKES!

So one of the biggest draw backs to this is the pure size of the Base64 string. It's huge! So would this be practical to be put onto the blockchain?

On further testing It can be placed inside the Json_metadata inside the block, using #Piston (Thanks @xeroc) I wrote little python script to place the actual Base64 string into the meta and it was successful. I will also post a comment right after I finish this post and do the same so everyone can take a look. It also posted, time wise, without any issues and when looking at the post via steemd, again no problems!

Now although I don't believe their to be any size limitations to Base64 other then: (source caniuse.com)

Although Mozilla supports data URIs of essentially unlimited length, browsers are not required to support any particular maximum length of data. For example, the Opera 11 browser limits data URIs to around 65000 characters.
Support in Internet Explorer 8 is limited to images and linked resources like CSS files, not HTML files. Max URI length in IE8 is 32KB. In IE9 JavaScript files are supported too and the maximum size limit set to 4GB.

I think it might be safe to say the Blockchain could handle images 1mb and under and I think that would handle a majority of images needed for posts and comments. And Yes, Gif's can be Base64, however a lot of these types of images are larger then 1mb so that may be a problem and the length of the string again would be even larger.

On a coding perspective it would be quite simple: Add to Steem within Posting Function around the image handler. (Possibly right before the https://img1.steemit.com/0x0 is added)

  1. import Base64
  2. While foudnImgSrc.Size <= 1000kb { encoded = base64.b64encode('foudnImgSrc')
    newImgURL = base64.b64decode(encoded) }
  3. json_metadata "{"tags": ["steemit"], "image1..2..3": ["data:image/data:image/jpeg;bas...
  4. img src = image1

Number 4 using the metadata tag to replace the image url on the page will save a on load times and the size of the blockchain. Also the max body length limit would be broken and the post would return comment pruned due to size

When it comes to displaying them its pretty straight forward however img1 steemit would have to be modified to handle the Base64 as well as normal images.

So there you have it, we could have images stored on the blockchain using Base64!
I'm going to call it a night for now but I'm going to continue my work on finding out our best solution for images on steemit.

Blue

Sort:  

Test one resulted in this: comment pruned due to size (because the full Base64 string image can't be inside the body

Check out the blockchain for this thread here: https://steemd.com/steemit-images/@blueorgy/steemit-images-under-1mb-could-be-stored-on-the-blockchain-using-base64

You can see the full Base64 string inside my other comment inside the Json_Metadata

Base64 Image >

I have been using it and very happy ! http://steemimg.com Thank you for your work!

Thanks for taking in consideration the conversation we've had. At this point you cannot do much unless you want to create your own Siacoin/Storj/Maidsafe, but that would require many months of work and a solid team of engineers. The only thing we can do is to just wait for their API's to further develop.

This would result in incredible block chain bloat requiring immense storage space on every node along with a vast increase in bandwidth usage in order to synchronize the nodes running the blockchain. Even if you could somehow reduce the size of a 1MB image file to 1% of its original size (strictly hypothetically speaking) given that 10s of thousands of images are or will be included in Steemit posts everyday, the blockchain bloat would be completely prohibitive.

Additionally there are possible copyright infringement implications if Steemit is used to store copyrighted images without the owners permission. There might still be some liability around linking to copyrighted images hosted on other websites but its certainly not as clear cut as hosting copyrighted content.

Very good point. Defiantly the biggest issue is the size no matter what way you look at it.

Yes hosting of copywriter images would be a bid deal because once the data is on the blockchain, its there for good. Although since its stored as Base64 encoded string it actually isn't being hosted , just like how apple hash emails when they sell them to third parties ... but thats all sticky stuff

With many crypto currency projects blockchain bloat is a big problem. The distributed blockchain model is not conducive to any content storage applications.

That might change with future storage technology? If it does, hermetic archive of data would be a valuable thing in some cases.

Interesting idea. I actually came here to see if the current library of images already lived on the block chain or not. I kinda already knew they didn't but wasn't sure. Now I know why. I don't know if it has been covered yet, but I wonder what consequences block chain based images might have for copyright and dmca takedown.

I find this post very interesting, but i cant understand a bit of it. can you explain it more n00b friendly?

Interesting concept! The problem with using Base64 encoded resources is that there is a 33% overhead! And as others have mentioned, embedding the images inside the post will make the blockchain grow out of hand. Maybe in future, steem can support binary objects BLOBs like in databases like mysql? It could be like how emails embed file attachments, though that is done as encoded text. If there is support for binary objects, at least there wouldn't be the overhead.

Or maybe steem can interface with Storj or MaidSafe for storing image resources?!

Yes I was doing more research and found the 33% larger aspect , will add this to the post. The blockchain is just not meant to support it!

Right, that is why I thought that if those resources could be stored as BLOB objects, then it would not have the overhead from the need to encode to text with base64. I don't know if Storz uses a blockchain but if it does, then it means they have accomplished such a task.

If this became commonplace though, wouldnt this dramatically accelerate the growth of the blockchain? You'd be multiplying the size of every post by what 100? 1000? Wouldnt every miner end up storing separate copies of every single image posted on Steem? Still its neat to see as a proof of concept.

Yes one of the biggest issues with this solution is this exactly.

Blockchain is very expensive system for storing image data (miners want reward). It's very useful for transaction/moving assets.
Then one more problem: suppose all images are written on immutable blockchain. One day we see post with child porno there. Hardfork?

Yes, extremely expensive system.
And :( very sad thought but very true.

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.031
BTC 58925.39
ETH 2498.15
USDT 1.00
SBD 2.48