Why do SpriteFrames saved with ResourceSaver weigh so much?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By WIND

I’m currently making a character creator for my game. The way you use it is by putting an image and a text file in the user folder.

The image is a sprite sheet, and the text file defines the coordinates in which the image will be cropped.
To crop the frames, i’m using the Image.get_rect() method. Then, i add the images as frames in a SpriteFrames node, and use the ResourceSaver class to save the resource in the user dir.
The problem is: those saved SpriteFrames weigh an ungodly amount more than the original files, even when i use the “compress” flag in the save() method.

Why does this happen?

What’s in the file? You should be able to open it in a text editor.

exuin | 2021-06-06 06:50

All it has are the elements that define the color of every pixel and the (very few) lines that define each one of the animations.

WIND | 2021-06-06 16:46

:bust_in_silhouette: Reply From: Calinou

This is likely because the image data is embedded into the file. If you save this file as a .tres file, binary data will be encoded as Base64, making it at least 33% larger. It will also load and save slower compared to a binary file.

To avoid this, save the SpriteFrames resource as a binary .res file, or better, ensure that all images are saved as external .png files.

Thank you so much! The resource files are still heavier than the original files, but have reduced in size by 50mb. I honestly can’t thank you enough!

WIND | 2021-06-10 20:04