diff --git a/Cargo.toml b/Cargo.toml index c9a26ae..7968463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "libcaesium" -version = "0.12.0" +version = "0.12.1" authors = ["Matteo Paonessa "] edition = "2021" categories = ["multimedia::images"] keywords = [ "compression", - "library", "jpeg", "png", "gif", @@ -21,19 +20,6 @@ homepage = "https://github.com/Lymphatus/libcaesium" repository = "https://github.com/Lymphatus/libcaesium" license = "Apache-2.0" -[dependencies] -mozjpeg-sys = { version = "1.0", optional = true } -oxipng = { version = "8.0", optional = true } -libc = "0.2" -gifsicle = { version = "1.92.5", optional = true } -webp = { version = "0.2.2", optional = true } -infer = "0.13.0" -image = { version = "0.24.6", default-features = false, features = ["jpeg", "png", "webp", "gif"] } -img-parts = "0.3" -bytes = "1.1" -lodepng = { version = "3.7", optional = true } -imagequant = {version = "4.1", optional = true} - [features] default = ["jpg", "png", "webp", "gif"] jpg = ["dep:mozjpeg-sys"] @@ -41,6 +27,19 @@ png = ["dep:oxipng", "dep:lodepng", "dep:imagequant"] webp = ["dep:webp"] gif = ["dep:gifsicle"] +[dependencies] +mozjpeg-sys = { version = "1.0", optional = true } +oxipng = { version = "8.0", optional = true } +libc = "0.2" +gifsicle = { version = "1.92.5", optional = true } +webp = { version = "0.2.2", optional = true } +infer = "0.15.0" +image = { version = "0.24.6", default-features = false, features = ["jpeg", "png", "webp", "gif"] } +img-parts = "0.3" +bytes = "1.1" +lodepng = { version = "3.7", optional = true } +imagequant = {version = "4.1", optional = true} + [dev-dependencies] dssim = "3.2.0" kamadak-exif = "0.5.4" diff --git a/README.md b/README.md index 4863b34..97b156a 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ Valid values for `jpeg_chroma_subsampling` are [444, 422, 420, 411]. Any other v Binaries not available. Please refer to the compilation section below. ## Compilation and Installation -Compilation is available for all supported platforms: Windows, MacOS and Linux. +Compilation is available for all supported platforms: Windows, macOS and Linux. ``` cargo build --release diff --git a/src/lib.rs b/src/lib.rs index d7f318d..8606c15 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,7 @@ pub struct CCSResult { #[derive(Copy, Clone)] pub struct JpegParameters { pub quality: u32, - pub chroma_subsampling: jpeg::ChromaSubsampling + pub chroma_subsampling: ChromaSubsampling } #[derive(Copy, Clone)] @@ -80,7 +80,7 @@ pub struct CSParameters { pub fn initialize_parameters() -> CSParameters { let jpeg = JpegParameters { quality: 80, - chroma_subsampling: jpeg::ChromaSubsampling::Auto + chroma_subsampling: ChromaSubsampling::Auto }; let png = PngParameters { @@ -247,14 +247,17 @@ pub fn compress_to_size( } let compressed_file = match file_type { + #[cfg(feature = "jpg")] SupportedFileTypes::Jpeg => { parameters.jpeg.quality = quality; jpeg::compress_to_memory(in_file.clone(), parameters)? //TODO clone } + #[cfg(feature = "png")] SupportedFileTypes::Png => { parameters.png.quality = quality; png::compress_to_memory(in_file.clone(), parameters)? //TODO clone } + #[cfg(feature = "webp")] SupportedFileTypes::WebP => { parameters.webp.quality = quality; webp::compress_to_memory(in_file.clone(), parameters)? //TODO clone diff --git a/tests/metadata.rs b/tests/metadata.rs index d178271..9f68954 100644 --- a/tests/metadata.rs +++ b/tests/metadata.rs @@ -88,7 +88,7 @@ fn extract_exif(path: &Path) -> HashMap { for f in exif.fields() { exif_map.insert( format!("{}", f.tag), - f.display_value().to_string() as String, + f.display_value().to_string(), ); }