2021-10-21 00:00:41 +00:00
|
|
|
use crate::process::Process;
|
2021-09-04 00:53:53 +00:00
|
|
|
use actix_web::web::Bytes;
|
2022-10-15 16:13:24 +00:00
|
|
|
use tokio::io::{AsyncRead, AsyncReadExt};
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace", skip(input))]
|
|
|
|
pub(crate) async fn needs_reorienting(input: Bytes) -> std::io::Result<bool> {
|
|
|
|
let process = Process::run("exiftool", &["-n", "-Orientation", "-"])?;
|
|
|
|
let mut reader = process.bytes_read(input);
|
|
|
|
|
|
|
|
let mut buf = String::new();
|
|
|
|
reader.read_to_string(&mut buf).await?;
|
|
|
|
|
|
|
|
Ok(!buf.is_empty())
|
|
|
|
}
|
2021-09-04 00:53:53 +00:00
|
|
|
|
2022-10-02 02:17:18 +00:00
|
|
|
#[tracing::instrument(level = "trace", skip(input))]
|
2021-09-04 00:53:53 +00:00
|
|
|
pub(crate) fn clear_metadata_bytes_read(input: Bytes) -> std::io::Result<impl AsyncRead + Unpin> {
|
2021-09-14 01:22:42 +00:00
|
|
|
let process = Process::run("exiftool", &["-all=", "-", "-out", "-"])?;
|
2021-09-04 00:53:53 +00:00
|
|
|
|
2022-04-07 02:40:49 +00:00
|
|
|
Ok(process.bytes_read(input))
|
2021-09-04 00:53:53 +00:00
|
|
|
}
|