From 33c23fef2560278ed4d5ec68b2535210a561b933 Mon Sep 17 00:00:00 2001
From: Louis <contact@louiscap.co>
Date: Sat, 1 Feb 2025 04:58:49 +0000
Subject: [PATCH] Fix imports for commands

---
 src/commands/atlas.rs    |  2 +-
 src/commands/extrude.rs  |  5 +++--
 src/commands/flip.rs     |  2 +-
 src/commands/pipeline.rs | 11 ++++-------
 src/commands/reduce.rs   |  2 +-
 src/commands/remap.rs    |  6 ++----
 src/commands/rotate.rs   |  2 +-
 src/commands/scale.rs    |  2 +-
 8 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/commands/atlas.rs b/src/commands/atlas.rs
index 4611367..6427a9e 100644
--- a/src/commands/atlas.rs
+++ b/src/commands/atlas.rs
@@ -1,4 +1,3 @@
-use crate::format::load_image;
 use clap::Parser;
 use etagere::{AllocId, AtlasAllocator, Rectangle, Size};
 use image::{image_dimensions, GenericImage, Rgba, RgbaImage};
@@ -9,6 +8,7 @@ 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 3c0e946..d69afe5 100644
--- a/src/commands/extrude.rs
+++ b/src/commands/extrude.rs
@@ -1,4 +1,3 @@
-use crate::utils::{RgbaOutputFormat, SpriteData};
 use clap::Parser;
 
 use image::math::Rect;
@@ -6,6 +5,7 @@ use image::{GenericImage, GenericImageView, Rgba, RgbaImage};
 
 use serde::{Deserialize, Serialize};
 use std::ops::Deref;
+use crunch_cli::utils::{RgbaOutputFormat, SpriteData};
 
 #[inline(always)]
 fn tile_size() -> u32 {
@@ -92,7 +92,8 @@ impl Extrude {
 		);
 		let mut new_image = RgbaImage::from_pixel(new_width, new_height, Rgba::from([0, 0, 0, 0]));
 		for sprite in views.iter() {
-			let (img_x, img_y, width, height) = sprite.data.bounds();
+			let (width, height) = sprite.data.dimensions();
+			let (img_x, img_y) = sprite.data.offsets();
 			let target_x = self.padding + img_x + (sprite.tx * self.space_x);
 			let target_y = self.padding + img_y + (sprite.ty * self.space_y);
 
diff --git a/src/commands/flip.rs b/src/commands/flip.rs
index 98b5375..ec06849 100644
--- a/src/commands/flip.rs
+++ b/src/commands/flip.rs
@@ -1,7 +1,7 @@
-use crate::utils::TypedOutputFormat;
 use clap::{Parser, ValueEnum};
 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/pipeline.rs b/src/commands/pipeline.rs
index db80112..4cf496c 100644
--- a/src/commands/pipeline.rs
+++ b/src/commands/pipeline.rs
@@ -5,12 +5,9 @@ use std::path::{Path, PathBuf};
 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};
-use crate::format::make_paths;
-use crate::load_image;
-use crate::utils::normalize_path;
 
 #[derive(Error, Debug)]
 pub enum PipelineError {
@@ -135,10 +132,10 @@ impl Pipeline {
 					}
 					Args::Remap(remap) => {
 						let palette = result!(load_image(&remap.palette, None));
-						let image_palette = result!(Palette::extract_from(&file));
-						let target_palette = result!(Palette::extract_from(&palette));
+						let image_palette = ColourPalette::from(&file);
+						let target_palette = ColourPalette::from(&palette);
 
-						let mappings = Palette::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 5c4f496..4a9b670 100644
--- a/src/commands/reduce.rs
+++ b/src/commands/reduce.rs
@@ -1,8 +1,8 @@
-use crate::utils::RgbaOutputFormat;
 use anyhow::Error;
 use clap::Parser;
 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 3dd3083..eba0544 100644
--- a/src/commands/remap.rs
+++ b/src/commands/remap.rs
@@ -1,10 +1,8 @@
-use crate::commands::palette::ColourMapping;
 use clap::Parser;
 use image::{GenericImage, Pixel, Rgba};
 use num_traits::ToPrimitive;
 use serde::{Deserialize, Serialize};
-
-use crate::utils::{new_image, BasicRgba, OutputFormat};
+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)]
@@ -25,7 +23,7 @@ pub struct Remap {
 impl Remap {
 	pub fn remap_image(
 		image: impl GenericImage,
-		mappings: ColourMapping,
+		mappings: PaletteMap,
 	) -> anyhow::Result<OutputFormat> {
 		let mut output = new_image(image.width(), image.height());
 		for (x, y, pixel) in image.pixels() {
diff --git a/src/commands/rotate.rs b/src/commands/rotate.rs
index 3531cb2..ba57825 100644
--- a/src/commands/rotate.rs
+++ b/src/commands/rotate.rs
@@ -1,7 +1,7 @@
-use crate::utils::TypedOutputFormat;
 use clap::{Parser, ValueEnum};
 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 256be47..81ce474 100644
--- a/src/commands/scale.rs
+++ b/src/commands/scale.rs
@@ -1,8 +1,8 @@
-use crate::utils::TypedOutputFormat;
 use clap::Parser;
 use image::imageops::FilterType;
 use image::{imageops, GenericImage, Pixel};
 use serde::{Deserialize, Serialize};
+use crunch_cli::utils::TypedOutputFormat;
 
 #[inline(always)]
 fn one() -> f32 {
-- 
GitLab