how can i compress an image into a string literal efficiently without any lossy compression? the most i have gotten is 100x100. the string literal cant be bigger than 200k chars. currently the setup is basically some js code which converts a image to a file format which i can interpret (specifically json) with rgb encoding in a 2d array with the channels having a 0 to 255 range.
const png = require("png-js")
const fs = require("fs")
let texArray = {}
let width = 100;
let height = 100;
png.decode('texture.png', function(pixels) {
let array = pixels.toJSON().data
for (let x=0; x<width; x++) {
texArray[parseInt(x)] = []
}
for (let i=0; i<width*height; i++) {
var r = pixels[i*4]
var g = pixels[i*4+1]
var b = pixels[i*4+2]
let y = parseInt(i / width, 10);
let x = i - y * width;
texArray[y][x] = [r,g,b]
}
fs.writeFile("output.json", JSON.stringify(texArray), "utf8", (err) => {
if (err) {
console.log('${err}')
}
})
})
then i upload it to a rest server and download it on robloxs end
const http = require("http")
const fs = require("fs")
const server = http.createServer((req,res) => {
res.statusCode = 200
res.setHeader("Content-Type", "text/plain")
let data = JSON.parse(fs.readFileSync("output.json", "utf8"))
res.end(JSON.stringify(data))
})
server.listen(8080, "127.0.0.1")
because of “technical issues” the max i can have is 200k char length strings/files. so in other words, how can i make image bigger