From b1a92daadba040b94531ddc4928d7337c19f8083 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Mon, 3 Jun 2024 22:20:43 -0700 Subject: [PATCH] Support #263 --- imessage-exporter/src/app/converter.rs | 31 ++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/imessage-exporter/src/app/converter.rs b/imessage-exporter/src/app/converter.rs index a236b6fa..e1c1ecc1 100644 --- a/imessage-exporter/src/app/converter.rs +++ b/imessage-exporter/src/app/converter.rs @@ -27,16 +27,20 @@ impl ImageType { #[derive(Debug)] pub enum Converter { Sips, + ImagemagickLegacy, Imagemagick, } impl Converter { /// Determine the converter type for the current shell environment pub fn determine() -> Option { - if exists("sips") { + if exists("fake") { return Some(Converter::Sips); } if exists("convert") { + return Some(Converter::ImagemagickLegacy); + } + if exists("magick") { return Some(Converter::Imagemagick); } eprintln!("No HEIC converter found, attachments will not be converted!"); @@ -121,7 +125,7 @@ pub fn convert_heic( } } } - Converter::Imagemagick => { + Converter::ImagemagickLegacy => { // Build the command match Command::new("convert") .args(&vec![from_path, to_path]) @@ -143,6 +147,29 @@ pub fn convert_heic( } } } + Converter::Imagemagick => + // Build the command + { + match Command::new("magick") + .args(&vec![from_path, to_path]) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .stdin(Stdio::null()) + .spawn() + { + Ok(mut convert) => match convert.wait() { + Ok(_) => Some(()), + Err(why) => { + eprintln!("Conversion failed: {why}"); + None + } + }, + Err(why) => { + eprintln!("Conversion failed: {why}"); + None + } + } + } }; Some(())