Skip to content

Instantly share code, notes, and snippets.

@sajattack
Created March 19, 2022 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajattack/feaf0df9bf0310616169609ffcb3b578 to your computer and use it in GitHub Desktop.
Save sajattack/feaf0df9bf0310616169609ffcb3b578 to your computer and use it in GitHub Desktop.
png2gu
[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"
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