Skip to content

Commit

Permalink
Support #263
Browse files Browse the repository at this point in the history
  • Loading branch information
ReagentX committed Jun 4, 2024
1 parent 482ccf6 commit b1a92da
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions imessage-exporter/src/app/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Converter> {
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!");
Expand Down Expand Up @@ -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])
Expand All @@ -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(())
Expand Down

0 comments on commit b1a92da

Please sign in to comment.