From ce7fb9b64107ae5ee7877e5e9be79cab6bdb8bc6 Mon Sep 17 00:00:00 2001
From: Louis <contact@louiscap.co>
Date: Sat, 1 Feb 2025 05:01:19 +0000
Subject: [PATCH] Fmt + lint

---
 src/cli_args.rs          | 2 +-
 src/commands/atlas.rs    | 2 +-
 src/commands/extrude.rs  | 2 +-
 src/commands/flip.rs     | 2 +-
 src/commands/palette.rs  | 4 ++--
 src/commands/pipeline.rs | 9 +++++----
 src/commands/reduce.rs   | 2 +-
 src/commands/remap.rs    | 2 +-
 src/commands/rotate.rs   | 2 +-
 src/commands/scale.rs    | 2 +-
 src/commands/split.rs    | 6 ------
 src/utils/colours.rs     | 2 +-
 src/utils/files.rs       | 5 ++---
 src/utils/formats.rs     | 6 +-----
 src/utils/mapping.rs     | 3 +--
 src/utils/palette.rs     | 6 +++---
 16 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/src/cli_args.rs b/src/cli_args.rs
index a53429e..accfa4b 100644
--- a/src/cli_args.rs
+++ b/src/cli_args.rs
@@ -97,7 +97,7 @@ impl Args {
 				let palette_data = load_image(&remap.palette, None)?;
 
 				let image_palette = ColourPalette::from(&image_data);
-				let target_palette =  ColourPalette::from(&palette_data);
+				let target_palette = ColourPalette::from(&palette_data);
 
 				let mappings = PaletteMap::calculate_mapping(&image_palette, &target_palette);
 				let output = Remap::remap_image(image_data, mappings)?;
diff --git a/src/commands/atlas.rs b/src/commands/atlas.rs
index 6427a9e..d76e57b 100644
--- a/src/commands/atlas.rs
+++ b/src/commands/atlas.rs
@@ -1,4 +1,5 @@
 use clap::Parser;
+use crunch_cli::utils::load_image;
 use etagere::{AllocId, AtlasAllocator, Rectangle, Size};
 use image::{image_dimensions, GenericImage, Rgba, RgbaImage};
 use rayon::prelude::{IntoParallelIterator, ParallelIterator};
@@ -8,7 +9,6 @@ use std::collections::HashMap;
 use std::fmt::Display;
 use std::fs::File;
 use std::path::PathBuf;
-use crunch_cli::utils::load_image;
 
 fn default_max_size() -> usize {
 	2048
diff --git a/src/commands/extrude.rs b/src/commands/extrude.rs
index d69afe5..959e8cb 100644
--- a/src/commands/extrude.rs
+++ b/src/commands/extrude.rs
@@ -3,9 +3,9 @@ use clap::Parser;
 use image::math::Rect;
 use image::{GenericImage, GenericImageView, Rgba, RgbaImage};
 
+use crunch_cli::utils::{RgbaOutputFormat, SpriteData};
 use serde::{Deserialize, Serialize};
 use std::ops::Deref;
-use crunch_cli::utils::{RgbaOutputFormat, SpriteData};
 
 #[inline(always)]
 fn tile_size() -> u32 {
diff --git a/src/commands/flip.rs b/src/commands/flip.rs
index ec06849..9a16d78 100644
--- a/src/commands/flip.rs
+++ b/src/commands/flip.rs
@@ -1,7 +1,7 @@
 use clap::{Parser, ValueEnum};
+use crunch_cli::utils::TypedOutputFormat;
 use image::{imageops, GenericImage, Pixel};
 use serde::{Deserialize, Serialize};
-use crunch_cli::utils::TypedOutputFormat;
 
 #[derive(Copy, Clone, Serialize, Deserialize, ValueEnum, Debug)]
 pub enum FlipDirection {
diff --git a/src/commands/palette.rs b/src/commands/palette.rs
index 5be4a31..a3cece4 100644
--- a/src/commands/palette.rs
+++ b/src/commands/palette.rs
@@ -1,8 +1,8 @@
 use clap::Parser;
 use std::cmp::min;
 
-use crunch_cli::utils::{new_image, BasicRgba, ColourPalette, PaletteFormat, PaletteMap};
-use image::{GenericImage, Pixel, Rgba};
+use crunch_cli::utils::{new_image, ColourPalette, PaletteFormat};
+use image::{GenericImage, Rgba};
 use serde::{Deserialize, Serialize};
 use std::io::Write;
 
diff --git a/src/commands/pipeline.rs b/src/commands/pipeline.rs
index 4cf496c..39e7b93 100644
--- a/src/commands/pipeline.rs
+++ b/src/commands/pipeline.rs
@@ -2,12 +2,12 @@ use clap::Parser;
 use std::collections::HashMap;
 use std::path::{Path, PathBuf};
 
+use crate::cli_args::Args;
+use crate::commands::Remap;
+use crunch_cli::utils::{load_image, make_paths, normalize_path, ColourPalette, PaletteMap};
 use rayon::prelude::*;
 use serde::{Deserialize, Serialize};
 use thiserror::Error;
-use crunch_cli::utils::{load_image, make_paths, normalize_path, ColourPalette, PaletteMap};
-use crate::cli_args::Args;
-use crate::commands::{Palette, Remap};
 
 #[derive(Error, Debug)]
 pub enum PipelineError {
@@ -135,7 +135,8 @@ impl Pipeline {
 						let image_palette = ColourPalette::from(&file);
 						let target_palette = ColourPalette::from(&palette);
 
-						let mappings = PaletteMap::calculate_mapping(&image_palette, &target_palette);
+						let mappings =
+							PaletteMap::calculate_mapping(&image_palette, &target_palette);
 						file = result!(Remap::remap_image(file, mappings));
 					}
 					_ => {}
diff --git a/src/commands/reduce.rs b/src/commands/reduce.rs
index 4a9b670..3301909 100644
--- a/src/commands/reduce.rs
+++ b/src/commands/reduce.rs
@@ -1,8 +1,8 @@
 use anyhow::Error;
 use clap::Parser;
+use crunch_cli::utils::RgbaOutputFormat;
 use image::GenericImage;
 use serde::{Deserialize, Serialize};
-use crunch_cli::utils::RgbaOutputFormat;
 
 /// Limit the number of colours by quantity or threshold
 #[derive(Debug, Clone, Parser, Serialize, Deserialize)]
diff --git a/src/commands/remap.rs b/src/commands/remap.rs
index eba0544..ed0a728 100644
--- a/src/commands/remap.rs
+++ b/src/commands/remap.rs
@@ -1,8 +1,8 @@
 use clap::Parser;
+use crunch_cli::utils::{new_image, BasicRgba, OutputFormat, PaletteMap};
 use image::{GenericImage, Pixel, Rgba};
 use num_traits::ToPrimitive;
 use serde::{Deserialize, Serialize};
-use crunch_cli::utils::{new_image, BasicRgba, OutputFormat, PaletteMap};
 
 /// Convert the colour space of an image to that of a given palette file
 #[derive(Debug, Clone, Parser, Serialize, Deserialize)]
diff --git a/src/commands/rotate.rs b/src/commands/rotate.rs
index ba57825..9517bfd 100644
--- a/src/commands/rotate.rs
+++ b/src/commands/rotate.rs
@@ -1,7 +1,7 @@
 use clap::{Parser, ValueEnum};
+use crunch_cli::utils::TypedOutputFormat;
 use image::{imageops, GenericImage, Pixel};
 use serde::{Deserialize, Serialize};
-use crunch_cli::utils::TypedOutputFormat;
 
 #[derive(Copy, Clone, Serialize, Deserialize, ValueEnum, Debug)]
 pub enum RotateDegree {
diff --git a/src/commands/scale.rs b/src/commands/scale.rs
index 81ce474..daedd3b 100644
--- a/src/commands/scale.rs
+++ b/src/commands/scale.rs
@@ -1,8 +1,8 @@
 use clap::Parser;
+use crunch_cli::utils::TypedOutputFormat;
 use image::imageops::FilterType;
 use image::{imageops, GenericImage, Pixel};
 use serde::{Deserialize, Serialize};
-use crunch_cli::utils::TypedOutputFormat;
 
 #[inline(always)]
 fn one() -> f32 {
diff --git a/src/commands/split.rs b/src/commands/split.rs
index d491bd8..ea72cc2 100644
--- a/src/commands/split.rs
+++ b/src/commands/split.rs
@@ -4,11 +4,6 @@ use num_traits::AsPrimitive;
 use serde::{Deserialize, Serialize};
 use std::path::PathBuf;
 
-#[inline(always)]
-fn tile_size() -> u32 {
-	32
-}
-
 /// Take a spritesheet and split into individual sprites, skipping empty space
 #[derive(Parser, Serialize, Deserialize, Clone, Debug)]
 #[clap(author, version = "0.8.0")]
@@ -96,7 +91,6 @@ impl Split {
 			for y in 0..rows {
 				let img_x = self.padding + (x * tile_width) + (x * self.space_x);
 				let img_y = self.padding + (y * tile_height) + (y * self.space_y);
-				// let img_y = y * self.tile_size;
 
 				let view = image.view(img_x, img_y, tile_width, tile_height);
 
diff --git a/src/utils/colours.rs b/src/utils/colours.rs
index dbc2083..b1e7ef4 100644
--- a/src/utils/colours.rs
+++ b/src/utils/colours.rs
@@ -3,7 +3,7 @@ use std::path::{Component, Path, PathBuf};
 
 use deltae::LabValue;
 use glam::Vec3;
-use image::{GenericImage, GenericImageView, Rgb, Rgba, RgbaImage, SubImage};
+use image::{GenericImage, Rgb, Rgba, RgbaImage, SubImage};
 use lab::Lab;
 
 #[derive(Clone, Copy)]
diff --git a/src/utils/files.rs b/src/utils/files.rs
index eaa98b8..2e68c4e 100644
--- a/src/utils/files.rs
+++ b/src/utils/files.rs
@@ -1,6 +1,5 @@
 use crate::utils::Format;
-use image::io::Reader;
-use image::{ImageError, RgbaImage};
+use image::{ImageError, ImageReader, RgbaImage};
 use std::path::Path;
 use thiserror::Error;
 
@@ -16,7 +15,7 @@ pub fn load_image(
 	path: impl ToString,
 	format: Option<Format>,
 ) -> anyhow::Result<RgbaImage, ImageLoadingError> {
-	let mut image = Reader::open(path.to_string())?;
+	let mut image = ImageReader::open(path.to_string())?;
 	let file = match format {
 		Some(format) => {
 			image.set_format(format.as_image_format());
diff --git a/src/utils/formats.rs b/src/utils/formats.rs
index 18be803..9cf866d 100644
--- a/src/utils/formats.rs
+++ b/src/utils/formats.rs
@@ -1,10 +1,6 @@
-use std::path::Path;
-
 use clap::ValueEnum;
-use image::io::Reader;
-use image::{ImageError, ImageFormat, RgbaImage};
+use image::ImageFormat;
 use serde::{Deserialize, Serialize};
-use thiserror::Error;
 
 #[derive(
 	Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug, Serialize, Deserialize, Default,
diff --git a/src/utils/mapping.rs b/src/utils/mapping.rs
index 46cdb59..075abe4 100644
--- a/src/utils/mapping.rs
+++ b/src/utils/mapping.rs
@@ -2,10 +2,9 @@ use crate::utils::palette::ColourPalette;
 use crate::utils::BasicRgba;
 use anyhow::Error;
 use deltae::{Delta, LabValue, DE2000};
-use image::{GenericImage, Pixel, Rgba};
+use image::{GenericImage, Pixel};
 use num_traits::ToPrimitive;
 use std::collections::HashMap;
-use std::hash::RandomState;
 use std::ops::{Deref, DerefMut};
 
 #[derive(Clone, Debug)]
diff --git a/src/utils/palette.rs b/src/utils/palette.rs
index 846a7b6..b5f088b 100644
--- a/src/utils/palette.rs
+++ b/src/utils/palette.rs
@@ -1,9 +1,9 @@
 use crate::utils::BasicRgba;
-use image::{GenericImage, Pixel, Rgba};
+use image::{GenericImage, Pixel};
 use num_traits::ToPrimitive;
 use std::cmp::Ordering;
 use std::collections::HashSet;
-use std::ops::{Deref, DerefMut, Index};
+use std::ops::{Deref, DerefMut};
 
 #[derive(Clone, Debug)]
 #[cfg_attr(
@@ -84,6 +84,6 @@ impl<I: GenericImage> From<&I> for ColourPalette {
 				_ => continue, // Ignore pixels with missing or invalid components
 			}
 		}
-		ColourPalette::from_iter(colours.into_iter())
+		ColourPalette::from_iter(colours)
 	}
 }
-- 
GitLab