[][src]Function pngcrush::crush

pub fn crush<P: AsRef<Path>>(path: P) -> Result<Vec<u8>, Box<dyn Error>>

Returns raw byte data of a crushed version of the PNG located at the given path

Arguments

  • path - a path-like object which points to the PNG to crush

Examples

use std::io::Write as _;
let data = pngcrush::crush("examples/uncrushed.png").unwrap();
let mut buffer = std::fs::File::create("examples/crushed.png").unwrap();
buffer.write_all(&data).unwrap();

Errors

This function will return an Err if:

  • The given path is invalid
  • There is an error reading the path's contents
  • There is an error while sending the HTTP request
  • There is an error copying the response data into the output buffer