Created
March 19, 2022 22:37
-
-
Save sajattack/feaf0df9bf0310616169609ffcb3b578 to your computer and use it in GitHub Desktop.
png2gu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "png2gu" | |
version = "0.1.0" | |
authors = ["Paul Sajna <sajattack@gmail.com>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
png = "0.16" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use png; | |
use std::fs::File; | |
use std::io::Write; | |
fn main() { | |
let args: Vec<String> = std::env::args().collect(); | |
let in_path = args[1].clone(); | |
let out_path = args[2].clone(); | |
let mut decoder = png::Decoder::new(File::open(in_path).unwrap()); | |
decoder.set_transformations(png::Transformations::BGR); | |
let (info, mut reader) = decoder.read_info().unwrap(); | |
let mut buf = vec![0; info.buffer_size()]; | |
reader.next_frame(&mut buf).unwrap(); | |
let mut output_file = File::create(out_path).unwrap(); | |
output_file.write(&buf).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment