// SPDX-FileCopyrightText: 2023 CELESTIFYX Team
// SPDX-License-Identifier: GPL-3.0-or-later

use anyhow::Result;
use image::DynamicImage;

use inkline::{
    ImageDisplay,
    DisplayConfig
};

fn main() -> Result<()> {
    let image: DynamicImage = image::open("/usr/share/pixmaps/archlinux-logo.png")?;

    let info_text: Vec<String> = vec![
        "Hello World!".to_string(),
        "This is Inkline (Image).".to_string(),
        "Made with ❤️ in Rust.".to_string(),
        "Developer: CELESTIFYX Team".to_string(),
        "Terminal backends supported:".to_string(),
        "- Kitty".to_string(),
        "- xterm with Sixel support".to_string(),
        "- iTerm2".to_string(),
        "".to_string(),
        "".to_string(),
        "".to_string(),
        "".to_string(),
        "".to_string(),
        "".to_string()
    ];

    let config: DisplayConfig = DisplayConfig::new().with_color_resolution(64).with_lines(info_text);
    let display: ImageDisplay = ImageDisplay::auto_with_config(config)?;

    match display.render(&image) {
        Ok(output) => print!("{}", output),

        Err(_) => {
            println!("  Please use a terminal that supports:");
            println!("  - Kitty");
            println!("  - xterm with Sixel support");
            println!("  - iTerm2");
        }
    }

    Ok(())
}
