From 0eee55aaf403a805800025ceb07f74e20f48a4c9 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Wed, 29 May 2024 00:28:17 -0700 Subject: [PATCH] Switch from using the `convert` command to `magick`. The `convert` command is deprecated by ImageMagick, and `magick` has been available since 8 years. Resolves: https://github.com/lgarron/folderify/issues/87 --- README.md | 4 ++-- src/command.rs | 8 ++++---- src/icon_conversion.rs | 14 +++++++------- src/{convert.rs => magick.rs} | 0 src/main.rs | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) rename src/{convert.rs => magick.rs} (100%) diff --git a/README.md b/README.md index d45c00c..1738836 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ python3 -m folderify --macOS 10.5 path/to/icon.png ## Other installation options -If you don't have Homebrew but you already have ImageMagick (the `convert` +If you don't have Homebrew but you already have ImageMagick (the `magick` binary) on your system, you can use the following: ### Install using Rust @@ -109,7 +109,7 @@ You should see a bunch of new `.iconset` folders and `.icns` files that were aut ### Dependencies -- [ImageMagick](https://www.imagemagick.org/) - for image processing (you should be able to run convert and identify on the commandline). +- [ImageMagick](https://www.imagemagick.org/) - for image processing (you should be able to run `magick` and `identify` on the commandline). - Included with macOS: - `iconutil` - Optional: diff --git a/src/command.rs b/src/command.rs index 1135aee..e566e72 100644 --- a/src/command.rs +++ b/src/command.rs @@ -3,15 +3,15 @@ use std::process::Command; use std::process::Stdio; use std::str::from_utf8; -use crate::convert::CommandArgs; use crate::error::CommandFailedError; use crate::error::CommandInvalidError; use crate::error::FolderifyError; use crate::error::GeneralError; +use crate::magick::CommandArgs; const DEBUG_PRINT_ARGS: bool = false; -const CONVERT_COMMAND: &str = "convert"; +const MAGICK_COMMAND: &str = "magick"; const IDENTIFY_COMMAND: &str = "identify"; pub(crate) const ICONUTIL_COMMAND: &str = "iconutil"; pub(crate) const OPEN_COMMAND: &str = "open"; @@ -77,8 +77,8 @@ pub(crate) fn run_command( Ok(output.stdout) } -pub(crate) fn run_convert(args: &CommandArgs, stdin: Option<&[u8]>) -> Result<(), FolderifyError> { - run_command(CONVERT_COMMAND, args, stdin)?; +pub(crate) fn run_magick(args: &CommandArgs, stdin: Option<&[u8]>) -> Result<(), FolderifyError> { + run_command(MAGICK_COMMAND, args, stdin)?; Ok(()) } diff --git a/src/icon_conversion.rs b/src/icon_conversion.rs index 1dfdedd..81faa2d 100644 --- a/src/icon_conversion.rs +++ b/src/icon_conversion.rs @@ -36,11 +36,11 @@ impl ProgressBarType { use crate::{ command::{ - run_command, run_convert, DEREZ_COMMAND, FILEICON_COMMAND, ICONUTIL_COMMAND, + run_command, run_magick, DEREZ_COMMAND, FILEICON_COMMAND, ICONUTIL_COMMAND, OSASCRIPT_COMMAND, REZ_COMMAND, SETFILE_COMMAND, SIPS_COMMAND, }, - convert::{density, BlurDown, CommandArgs, CompositingOperation}, error::{FolderifyError, GeneralError}, + magick::{density, BlurDown, CommandArgs, CompositingOperation}, options::{Badge, ColorScheme, Options, SetIconUsing}, primitives::{Dimensions, Extent, Offset, RGBColor}, resources::{get_badge_icon, get_folder_icon}, @@ -308,7 +308,7 @@ impl IconConversion { args.extent(&Extent::no_offset(centering_dimensions)); let output_path = self.output_path("0.0_FULL_MASK.png"); args.push_path(&output_path); - run_convert(&args, None)?; + run_magick(&args, None)?; self.step(""); Ok(output_path) } @@ -329,7 +329,7 @@ impl IconConversion { }); let output_path = self.output_path("1.0_SIZED_MASK.png"); args.push_path(&output_path); - run_convert(&args, None)?; + run_magick(&args, None)?; Ok(output_path) } @@ -345,7 +345,7 @@ impl IconConversion { let file_name = format!("{}.png", output_filename); let output_path = self.output_path(&file_name); args.push_path(&output_path); - run_convert(&args, None)?; + run_magick(&args, None)?; Ok(output_path) } @@ -462,7 +462,7 @@ impl IconConversion { args.push_path(&top_bezel); args.composite(&CompositingOperation::dissolve); args.push_path(output_path); - run_convert(&args, Some(template_icon))?; + run_magick(&args, Some(template_icon))?; Ok(()) } @@ -481,7 +481,7 @@ impl IconConversion { args.push("-"); args.composite(&CompositingOperation::dissolve); args.push_path(icon_path); - run_convert(&args, Some(badge_icon)) + run_magick(&args, Some(badge_icon)) } // TODO diff --git a/src/convert.rs b/src/magick.rs similarity index 100% rename from src/convert.rs rename to src/magick.rs diff --git a/src/main.rs b/src/main.rs index 0bd4153..3892e3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,16 @@ use std::thread::{self, JoinHandle}; use command::{run_command, OPEN_COMMAND}; -use convert::CommandArgs; use icon_conversion::{IconInputs, IconResolution, WorkingDir}; use indicatif::MultiProgress; +use magick::CommandArgs; use crate::{output_paths::PotentialOutputPaths, primitives::Dimensions}; mod command; -mod convert; mod error; mod icon_conversion; +mod magick; mod options; mod output_paths; mod primitives;