Orama-Interactive / Pixelorama

Unleash your creativity with Pixelorama, a powerful and accessible open-source pixel art multitool. Whether you want to create sprites, tiles, animations, or just express yourself in the language of pixel art, this software will realize your pixel-perfect dreams with a vast toolbox of features. Available on Windows, Linux, macOS and the Web!
https://orama-interactive.itch.io/pixelorama
MIT License
6.83k stars 372 forks source link

Change the file format of pxo to be a ZIP #952

Closed OverloadedOrama closed 8 months ago

OverloadedOrama commented 8 months ago

Implements #939, solution 1. This PR makes .pxo files be .zip files in disguise, i.e., changing the extension from pxo to zip actually lets you open the file in a archive manager and view its content. Breaks forward compatibility with 0.x, meaning that pxo files exported with 1.x will not be able to be imported in 0.x. The opposite is true, however, pxos made with 0.x can be imported in 1.x.

Also provides an option to include the final blended images of each layer for easier importing by other software, and exporting with CLI, when it gets implemented. The option is disabled by default so save disk space and to reduce saving time.

The main reasons I think this solution is better than going with SQLite is that Godot already supports zip packing and reading, while SQLite would require a GDExtension which could be troublesome for cross-platform support, such as Web, and the second reason is that zips should be easier to import by other software. Any Godot 4-made software/addons can read zip files, for example.

Most project files seem to be smaller as zips compared to the previous pxo format. A 200x128 project with 15 layers and 159 frames when exported to the previous pxo format, with ZSTD compression, takes 3.1MB of space. The same project takes just 1.6MB as a zip, and 2.2MB as a zip when the final blended images are included. However, both loading and saving seems to be taking longer than the previous format. Saving could perhaps get optimized by just overwriting only the files that have new changes, and not remaking the entire file from scratch, but that's something for the future. This optimization is something that couldn't have been done so easily with the previous format, if at all.

The structure of the zip is the following (files are in italic, the rest are directories):

root ├── image_data │ ├── frames │ │ └── 1 │ │ | └── _layer1 │ │ | └── _layer2 │ │ | └── _layer3... etc for each layer │ │ └── 2 │ │ └── 3... etc for each frame │ └── brushes │ │ └── _brush1 (etc for each project brush) │ └── final_images (only included if "Include blended images" is enabled when saving) │ │ └── 1 │ │ └── 2 │ │ └── 3... etc for each frame │ └── _tilemask ├── data.json

Note that saving doesn't currently work on the Web version due to https://github.com/godotengine/godot/issues/85564.