An example 1 picture 25x25 pixels takes about 650 bytes

As text ??bosapara wrote:What is the better way to save pictures as text?
Yep, as text. An example we save some pixel art (an example from let's paint mod)neoh4x0r wrote: As text ?? Do mean you want to generate ASCII art from a photo ?
(If not then you can't save a photo as text, unless you want garbage data).
One of problem is can we delete data from any storage when we delete item?Eran wrote:Better to use mod storage or maybe directly write to a file.
Alright, I get it now....bosapara wrote:Yep, as text. An example we save some pixel art (an example from let's paint mod)neoh4x0r wrote: As text ?? Do mean you want to generate ASCII art from a photo ?
(If not then you can't save a photo as text, unless you want garbage data).
as "abcdefg" (a=black, b=white, c=red and etc), then open as formspec and can see some picture.
You are assuming that each pixel takes a megabyte, which is a bit (actually a bunch of bits) more than needed. Images still get big quickly though.neoh4x0r wrote: It should be noted that this is a really bad way to store image data -- it is essentially uncompressed data where the size of the image will be a 2nd order polynomial: y = x^2 .
An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
thanks, will checkGreenDimond wrote:My skinmaker mod saves and loads images as PNG. Perhaps take a look at it.
A few wrong, I would save it like meta as item, then just open this picture like formspec (on_use).neoh4x0r wrote:You don't want to save a picture as a text string.....you want to generate a picture from text (in-game) (where each letter represents a pixel with a given color).
An image 25*25 takes 625 bytes of text for meta, an example below:neoh4x0r wrote:An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
Code: Select all
abcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijk
No, I am not assuming....Eran wrote:You are assuming that each pixel takes a megabyte, which is a bit (actually a bunch of bits) more than needed. Images still get big quickly though.neoh4x0r wrote: It should be noted that this is a really bad way to store image data -- it is essentially uncompressed data where the size of the image will be a 2nd order polynomial: y = x^2 .
An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
I saved your text string to a file and the size of the file was 625 bytes + 1 byte (1 byte per letter) -- and by inference a 64x64 image will take a proportional amount of storage (1024 MB).bosapara wrote:An image 25*25 takes 625 bytes of text for meta, an example below:
Code: Select all
abcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijkabcdefghijklmnabcdefghijk
You clearly said a 32x32 image would take up 1GB of space. That is absurd. In this case, it would take up just over a kilobyte of space. A real 32x32 image (with 8 bit color) would be around 8kb.neoh4x0r wrote:No, I am not assuming....Eran wrote:You are assuming that each pixel takes a megabyte, which is a bit (actually a bunch of bits) more than needed. Images still get big quickly though.neoh4x0r wrote: It should be noted that this is a really bad way to store image data -- it is essentially uncompressed data where the size of the image will be a 2nd order polynomial: y = x^2 .
An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
We aren't talking about actual pixels here....
They are wanting to use characters to represent a colored pixel and would require 1 byte (8-bits) per character.
A picture would be represented by a sequence of characters: abcdefg, etc -- and then display it in a formspec.
I don't know why my eyes wanted to insert something that wasn't there.GreenDimond wrote:You clearly said a 32x32 image would take up 1GB of space. That is absurd. In this case, it would take up just over a kilobyte of space. A real 32x32 image (with 8 bit color) would be around 8kb.
neoh4x0r wrote:I saved your text string to a file and the size of the file was 625 bytes + 1 byte (1 byte per letter) -- and by inference a 64x64 image will take a proportional amount of storage (1024 MB).
Again, this is absurd. You must have your conversions wrong.neoh4x0r wrote:That's because the pixels are not encoded as RGB integers but as a string of characters "abcdefghijklmnabcdefghijkab...."GreenDimond wrote:You clearly said a 32x32 image would take up 1GB of space. That is absurd. In this case, it would take up just over a kilobyte of space. A real 32x32 image (with 8 bit color) would be around 8kb.
It is not. Skins are 64x32, and as noted in the README, any size image can be displayed in a formspec.You will definitely need to use a compression / decompression algorithm such as for png in GreenDimond's skinmaker -- however, that code was limited to 16x16 pixels.
I was refereing to: https://github.com/GreenXenith/skinmake ... -this-workGreenDimond wrote: It is not. Skins are 64x32, and as noted in the README, any size image can be displayed in a formspec.
How does this work?
This mod is limited to 16x16 textures due to the method used and the limitations of the Minetest engine.
The Drawbacks
The reason Aurailus' mod is limited to 16x16 is the hard limit on texture modifiers used in nodes. Entities do not share this limit.
Assumptions:neoh4x0r wrote:An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
I see 5.0.1 version using restrictions for text length 10000 symbols as metadata for books.neoh4x0r wrote:Let's face it.....this is a very inefficient method to store image data -- and it is the very reason that we have image compression/decompression algorithms.
Well it has to do with how binary values are stored -- kilobyte (base-10) vs kibibyte (base-2).GreenDimond wrote:(Also, 1024bytes is a little more than a kilobyte)
Yes, I know......my brain was thinking megabyte when it was actually seeing kilobytes -- it was an I/O error.Krock wrote:Assumptions:neoh4x0r wrote:An image of 32 x 32 pixels will need 1024 MB (1 GB) and a 64 x 64 image will be need more than 4096 MB (4 GB) of storage/memory.
* 32-bit color depth (4 bytes per pixel: RGB+A)
* Raw byte encoding, bitmap-like
* No ^[combine strings or whatsoever
Calculation: size_MiB = 4 * width * height / 1024^2
Reverse: an image of 32768 pixels in width and height would result in your calculated 4 GiB.
Even ^[combine is more efficient than your calculations (~27x the byte count): https://github.com/minetest/minetest/issues/6821
Code: Select all
4 kilobytes = 4 * (2^10) = 2^2 * 2^10 = 2^12 bytes ; sqrt(2^(12/2) ; 64x64
4 megabytes = 4 * (2^10 * 2^10) = 2^2 * 2^20 = 2^24 bytes ; sqrt(2^(24/2) ; 4096x4096
4 gibabytes = 4 * (2^10 * 2^10 * 2^10) = 2^2 * 2^30 = 2^32 bytes ; sqrt(2^(32/2) ; 65536x65536
Users browsing this forum: No registered users and 2 guests