icns-rs

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

commit 113386ffd148f8002b723f5d22f95eb05e9cdd65
parent 17aa55bf2045e4919cace7e935da49ae34da76a4
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Mon, 31 Dec 2018 21:11:14 +1300

[+] Handling piping.

Piping mode is engaged when no input/output flags are provided.

Diffstat:
Msrc/main.rs | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,7 +1,7 @@ mod encode; mod os_type; -use std::io::BufWriter; +use std::io::{self, BufReader, BufWriter}; use std::fs::File; use clap::{App, Arg}; use image; @@ -30,5 +30,16 @@ fn main() { .expect("creating output file")); Encoder::new(out).encode(&src.to_rgba()) .expect("encoding icns"); + } else { + let mut buf: Vec<u8> = vec![]; + let stdin = io::stdin(); + let mut stdin = BufReader::new(stdin.lock()); + io::copy(&mut stdin, &mut buf) + .expect("reading from stdin"); + let src = image::load_from_memory(&buf) + .expect("decoding input image"); + Encoder::new(BufWriter::new(io::stdout().lock())) + .encode(&src.to_rgba()) + .expect("encoding icns"); } } \ No newline at end of file