Using images in json (base 64 encoding)

Learn here how to create and use plugins.

Moderator: Plugin Moderators

cesareborgia94
Inhabitant of a Continent
Reactions:
Posts: 1277
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy 360H

Platform

Plugin Creator

Using images in json (base 64 encoding)

#1

Post by cesareborgia94 » Sun Oct 07, 2018 5:02

Hello,
In the recent update (520), there was a new addition to json which is adding images to json using base64 encoding.

The question I would like to ask is:
1. What does adding images to json mean? What functionality could we use it in plugins?

2. How does the code work? What is the example of adding images to json will do?

I hope Lobby and other experienced plugin makers could explain this. It may be complex stuff but I still want to know what does it do.
I rarely make plugins now, but I still make them in spare time.
Disclaimer Please no request, I'm busy with real life stuff, I hope you understand ;)
You can find me here only. Discord is sh**, sorry JA :(

User avatar
CommanderABab
AB
Reactions:
Posts: 7933
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Using images in json (base 64 encoding)

#2

Post by CommanderABab » Sun Oct 07, 2018 6:39

.
Lobby wrote: 1. Use a website like https://www.freeformatter.com/base64-encoder.html to encode an image file to base64
2. insert the base64 string into the bmp tag.


Code: Select all

[  {
    "id":"$sloth00",
    "type":"terrain",
    "width":1,
    "height":1,
    "frames":[{"bmp":"/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMS4xAP/bAEMAGhITFxMQGhcVFx0bGh8nQConIyMnTzg8L0BdUmJhXFJaWWd0lH5nbYxvWVqBr4KMmZ6mp6ZkfLbDtKHBlKOmn//bAEMBGx0dJyInTCoqTJ9qWmqfn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn//AABEIABoAGgMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AOgeUKuFILdAPeqc+oImI5GAcEZxVK6vhDcZlBO7nAwcVRvblZ1aZCwCgfKR1zx+FK4I2WLFA64dQc467eKyzNIxJ2gZ5xxWbCbnIaF3wR/CcZHpV0xuSTlPz/8Ar0mVYvXsG9Mj7/QEDGKpNbziFyyEqfvYHXofy/wrXPShPv0hIxVLFRFAdoU45HJHrT/spP8Ayyz75/8ArUWygahKABgMcD061IWOTyfzoaHc/9k="}]
  }]
Screenshot_20181007-001513.jpg
777!777Currently using alpha 777. 777 What's new? :)
online maps!!
:)

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

cesareborgia94
Inhabitant of a Continent
Reactions:
Posts: 1277
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy 360H

Platform

Plugin Creator

Re: Using images in json (base 64 encoding)

#3

Post by cesareborgia94 » Sun Oct 07, 2018 10:25

Thank you Lobby and Commander for teaching me the basics of using images in json using base 64 encoding.

Although why do plugin creators could use base64 for images? Is it for security?
I rarely make plugins now, but I still make them in spare time.
Disclaimer Please no request, I'm busy with real life stuff, I hope you understand ;)
You can find me here only. Discord is sh**, sorry JA :(

User avatar
Lobby
Developer
Reactions:
Posts: 3384
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Using images in json (base 64 encoding)

#4

Post by Lobby » Sun Oct 07, 2018 11:14

Base64 is just an encoding, not an encryption :)
The feature here is to be able to create plugins that only consist of a single json file that contains all the images in textual representation (that's what base64 is about).
...Have a nice stay

User avatar
FranchuFranchu
Inhabitant of a Country
Reactions:
Posts: 797
Joined: Sun May 28, 2017 0:07
Location: Melting in Argentina
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Using images in json (base 64 encoding)

#5

Post by FranchuFranchu » Sun Oct 07, 2018 19:12

So no plugin texture space problems?
Did you know you can't blink while smiling :) ?

cesareborgia94
Inhabitant of a Continent
Reactions:
Posts: 1277
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy 360H

Platform

Plugin Creator

Re: Using images in json (base 64 encoding)

#6

Post by cesareborgia94 » Sun Oct 07, 2018 21:10

It is quite a nice feature, so you still make a plugin texture and it is contained in the encoding... I may use it for my future plugins :)

But I need to experiment first...
I rarely make plugins now, but I still make them in spare time.
Disclaimer Please no request, I'm busy with real life stuff, I hope you understand ;)
You can find me here only. Discord is sh**, sorry JA :(

User avatar
Lobby
Developer
Reactions:
Posts: 3384
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Using images in json (base 64 encoding)

#7

Post by Lobby » Sun Oct 07, 2018 22:02

@FranchuFranchu unfortunately not, there's no magic involved. The game does nothing else than getting the image out of the json and putting it into the plugin texture, like with any other image, too.

It's indeed more a neat feature than new functionality.
...Have a nice stay

cesareborgia94
Inhabitant of a Continent
Reactions:
Posts: 1277
Joined: Sun Nov 12, 2017 9:23
Location: The Kingdom of Babilandia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy 360H

Platform

Plugin Creator

Re: Using images in json (base 64 encoding)

#8

Post by cesareborgia94 » Sun Oct 07, 2018 22:36

So this is an example of the usage of base 64 encoding using my res building. This is just a test to see it works...
How the bulding looks like in the game, it is a res building with a purple 64 painted on its wall. Has no influences, just a normal res building except it is encoded with base 64
How the bulding looks like in the game, it is a res building with a purple 64 painted on its wall. Has no influences, just a normal res building except it is encoded with base 64
Download test base 64 plugin here:
newbase64.json
First base 64 encoding image in game. First test. Download this json and put it in the Theotown plugin folder. Lets hope it works ;)
(2.61 KiB) Downloaded 21 times
If it works, I may use it for future plugin creations. It is quite convenient that you only need to post the json code only without images added in a zip file.
I rarely make plugins now, but I still make them in spare time.
Disclaimer Please no request, I'm busy with real life stuff, I hope you understand ;)
You can find me here only. Discord is sh**, sorry JA :(

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 3 guests