refactor(tools): cleanup and make clippy a little happier

Uses a crate now for extracing image meta data, instead of our own hand rolled code.
This commit is contained in:
dignifiedquire
2019-08-14 15:05:09 +02:00
committed by Floris Bruynooghe
parent 29d4f6888d
commit 712f5a9782
7 changed files with 226 additions and 245 deletions

View File

@@ -1126,20 +1126,10 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
}
"fileinfo" => {
ensure!(!arg1.is_empty(), "Argument <file> missing.");
let mut buf = 0 as *mut libc::c_uchar;
let mut buf_bytes = 0;
let mut w = 0;
let mut h = 0;
if 0 != dc_read_file(
context,
arg1_c,
&mut buf as *mut *mut libc::c_uchar as *mut *mut libc::c_void,
&mut buf_bytes,
) {
dc_get_filemeta(buf as *const libc::c_void, buf_bytes, &mut w, &mut h);
println!("width={}, height={}", w, h,);
free(buf as *mut libc::c_void);
if let Some(buf) = dc_read_file_safe(context, &arg1) {
let (width, height) = dc_get_filemeta(&buf)?;
println!("width={}, height={}", width, height);
} else {
bail!("Command failed.");
}