Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support #263 #268

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading