krita 0.2.1

Parser for Krita files
Documentation
// Copyright (c) 2020 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::error::Error;
use krita::Kra;

fn main() -> Result<(), Box<dyn Error>> {
    let args: Vec<_> = std::env::args().collect();
    if args.len() != 2 {
        eprintln!("Usage: {} <file.kra>", args[0]);
        panic!();
    }

    let filename = &args[1];

    let kra = Kra::open(filename)?;
    let kra = kra.read_maindoc()?;

    let name = kra.get_name();
    let description = kra.get_description();
    let colorspace = kra.get_colorspace();
    let (width, height) = kra.get_dimensions();
    println!("{}{} {}×{} {}", name, description, width, height, colorspace);

    for layer in kra.iter() {
        let layer = kra.parse_layer(layer);
        println!("{:?}", layer);
    }

    Ok(())
}