icns-rs

Easily create .icns files (Mac Icons) with this Rust library or the included CLI app.
Log | Files | Refs | LICENSE

commit fe1e656a7d80553c9943bf69f1d58ea6bfb6934c
parent dd85b7c73a3c734bbe8baa275dbd352c522d6689
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Mon, 31 Dec 2018 20:43:33 +1300

[+] Accept png input and produce icns output, from flags.

Diffstat:
MCargo.toml | 9+++++++++
Asrc/main.rs | 33+++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -4,10 +4,19 @@ version = "0.1.0" authors = ["Jack Mordaunt <jackmordaunt@gmail.com>"] edition = "2018" +[lib] +name = "icns" +path = "src/lib.rs" + +[[bin]] +name = "icnsify" +path = "src/main.rs" + [dependencies] image = "0.20.1" byteorder = "1.2.7" rayon = "1.0.3" +clap = "2.32.0" [dev-dependencies] clap = "2.32.0" diff --git a/src/main.rs b/src/main.rs @@ -0,0 +1,32 @@ +mod encode; +mod os_type; + +use std::io::BufWriter; +use std::fs::File; +use clap::{App, Arg}; +use image; +use icns::Encoder; + +fn main() { + let matches = App::new("icnsify") + .version("0.1.0") + .author("Jack Mordaunt <jackmordaunt@gmail.com>") + .about("easily create icns icons from png images") + .arg(Arg::with_name("input") + .short("i") + .takes_value(true) + .help("path to input file")) + .arg(Arg::with_name("output") + .short("o") + .takes_value(true) + .help("path to output file")) + .get_matches(); + if let (Some(input), Some(output)) = (matches.value_of("input"), matches.value_of("output")) { + let input = image::open(&input) + .expect("decoding input image"); + let output = BufWriter::new(File::create(&output) + .expect("creating output file")); + Encoder::new(output).encode(&input.to_rgba()) + .expect("encoding icns"); + } +} +\ No newline at end of file