-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding .png images to base64 produces several times more data than expected #25571
Comments
This is expected. If you want to encode source |
You are right, I have updated my code to replace |
@Rriik So it is fixed? |
the respective issue was fixed, however I'm stuck trying to figure out how to then load that saved base64 data onto another image object. I tried this so far
However, it gives me an error saying |
Nevermind, I changed |
Closing as solved then :) |
Godot version: 3.0.6
OS: Windows 10 Pro
Issue description:
I tried encoding several image objects to base64 using
Marshalls.variant_to_base64()
, and what I found is that the encoding produces several times as as much data as it should on a blank file.Tested it with a 91 KB image and it resulted in a 186 KB output, 2x the size of the image.
Tested it with a 134 KB image and it resulted in a 470 KB output, 3.5x the size of the image.
The images i was trying to encode are .png files, so I'm not entirely sure whether that plays a role in the file size or whether the output sizes are different for .jpg or other image files, however I ran the same .png files through an online image-to-base64 encoding website (https://www.base64-image.de/) and it produced outputs of 123 KB and 185 KB respectively, both of which corresponding to average estimates for the encoding of about 4/3 times the size of the image. I also tried to get the PoolByteArray raw data from the image object, thinking that it's perhaps encoding non-necessary information together with the image data, but it produced the exact same results.
Steps to reproduce:
Copy this code in a blank project GDScript, add any image you want encoded in base64 to the project and copy its path to the code.
The text was updated successfully, but these errors were encountered: