10 releases

0.3.8 Mar 14, 2024
0.3.7 Mar 3, 2024
0.3.6 Jun 30, 2023
0.3.5 Apr 24, 2022
0.2.0 Mar 27, 2021

#78 in Images

Download history 21/week @ 2024-01-01 90/week @ 2024-01-08 53/week @ 2024-01-15 35/week @ 2024-01-22 27/week @ 2024-01-29 76/week @ 2024-02-05 59/week @ 2024-02-12 156/week @ 2024-02-19 230/week @ 2024-02-26 159/week @ 2024-03-04 296/week @ 2024-03-11 199/week @ 2024-03-18 121/week @ 2024-03-25 238/week @ 2024-04-01 133/week @ 2024-04-08 113/week @ 2024-04-15

641 downloads per month
Used in 10 crates (7 directly)

MIT license

165KB
3.5K SLoC

asefile

Build status crates.io Documentation

Utilities for loading Aseprite files. This library directly reads the binary Aseprite files (specification) and does not require you to export files to JSON. This should make it fast enough to load your assets when the game boots up (during development). You can also use it to build your own asset pipelines.

Documentation | Changelog

Example

use std::path::Path;

use asefile::AsepriteFile;
use image::{self, ImageFormat};

fn main() {
    let file = Path::new("input.aseprite");
    // Read file into memory
    let ase = AsepriteFile::read_file(&file).unwrap();
    // Write one output image for each frame in the Aseprite file.
    for frame in 0..ase.num_frames() {
        let output = format!("output_{}.png", frame);
        // Create image in memory, then write it to disk as PNG.
        let img = ase.frame(frame).image();
        img.save_with_format(output, ImageFormat::Png).unwrap();
    }
}

Unsupported Features

The following features of Aseprite 1.2.25 are currently not supported:

  • color profiles

Bug compatibility

  • For indexed color files Aseprite supports blend modes, but ignores them when exporting the image. The images constructed by asefile currently match the in-editor preview.

  • Aseprite has a bug in its luminance and color blend modes. Since this is the same in editor and in exported files, asefile reproduces this bug. (If Aseprite fixes this, asefile will fix this bug based on the version that the file was generated with.)

Dependencies

~10MB
~35K SLoC