diff --git a/crates/image-codecs/README.md b/crates/image-codecs/README.md index 3810df71d2..e059a423a6 100644 --- a/crates/image-codecs/README.md +++ b/crates/image-codecs/README.md @@ -58,7 +58,7 @@ craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "< | Cineon | yes | yes | U16 (10-bit code values read and written exactly through U16) | Gray, RGB | no | no | no | no | no | no | no | built in | | DICOM | yes | **no** | U8, U16 | Gray, RGB | no | no | no | no | no | no | n/a | built in | | Amiga IFF (ILBM/PBM) | yes | yes (24-bit ILBM) | U8 | RGB, RGBA | yes (1-bit mask plane on write) | no | no | no | no | no | no | built in | -| JPEG 2000 (`.jp2`, `.j2k`) | with feature `jp2` | **no** | U8 | Gray, GrayA, RGB, RGBA, CMYK | yes | yes | no | no | no | no | no | `hayro-jpeg2000` (off by default, so an SVG or raster reader carries no PDF decoder family) | +| JPEG 2000 (`.jp2`, `.j2k`) | with feature `jp2` (default) | **no** | U8 | Gray, GrayA, RGB, RGBA, CMYK | yes | yes | no | no | no | no | no | `hayro-jpeg2000` | | Sun Raster (`.ras`) | with feature `sunraster` (incl. RLE and colour maps) | with feature `sunraster` (uncompressed) | U8 | Gray, RGB, RGBA | yes | no | no | no | no | no | no | `sunraster` (off by default) | | SGI (`.sgi`, `.rgb`, `.bw`) | with feature `sgi` | with feature `sgi` (RLE) | U8, U16 | Gray, Gray+A, RGB, RGBA | yes | no | no | no | no | no | no | `sgi` (off by default) | | JPEG-LS (`.jls`) | yes (any NEAR; one scan per component) | yes (lossless) | U8, U16 | Gray, RGB | no | no | no | no | no | no | no | built in | @@ -79,6 +79,7 @@ off and lists the ones it needs; the codecs left out, and their dependencies, ar | `exr` | OpenEXR, with deep data, Cryptomatte and `exr_stream` (the `exr` dependency) | | `fits` | FITS | | `iff` | Amiga IFF | +| `jp2` | JPEG 2000 decode (`hayro-jpeg2000`) | | `jpegls` | JPEG-LS | | `jxl-encode` | JPEG XL export (the `zune-jpegxl` dependency); decode is the separate `jxl` feature | | `pnm` | Netpbm | @@ -86,7 +87,7 @@ off and lists the ones it needs; the codecs left out, and their dependencies, ar | `webp` | WebP, with the VP8 encoder (the `image-webp` dependency) | | `xpm` | XPM | -PNG, JPEG, TIFF, GIF, BMP, ICO, QOI, Radiance HDR, PCX and JPEG 2000 are always built. A format left +PNG, JPEG, TIFF, GIF, BMP, ICO, QOI, Radiance HDR and PCX are always built. A format left out is still detected; reading or writing it returns `CodecError::Unsupported` naming the feature, and its `caps` say it can be neither read nor written. The functions specific to a left-out format (`exr_info`, `decode_webp_frames`, `webp_encoding`, `xpm_named_color_rgb`...) are not compiled in. diff --git a/crates/image-codecs/src/lib.rs b/crates/image-codecs/src/lib.rs index b4dd2a48fa..671f18c45a 100644 --- a/crates/image-codecs/src/lib.rs +++ b/crates/image-codecs/src/lib.rs @@ -95,12 +95,12 @@ use crate::codecs::exr; use crate::codecs::fits; #[cfg(feature = "iff")] use crate::codecs::iff; +#[cfg(feature = "jp2")] +use crate::codecs::jp2; #[cfg(feature = "jpegls")] use crate::codecs::jpegls; #[cfg(feature = "pnm")] use crate::codecs::pnm; -#[cfg(feature = "jp2")] -use crate::codecs::jp2; #[cfg(feature = "sgi")] use crate::codecs::sgi; #[cfg(feature = "sunraster")] diff --git a/crates/image-codecs/tests/it/detect_caps.rs b/crates/image-codecs/tests/it/detect_caps.rs index 0f6d58d393..66a30f1c1d 100644 --- a/crates/image-codecs/tests/it/detect_caps.rs +++ b/crates/image-codecs/tests/it/detect_caps.rs @@ -471,6 +471,7 @@ fn each_component_scan_uses_the_restart_interval_in_effect_at_it() { assert!(matches!(decode(&with_dri(3, 2)), Err(CodecError::Unsupported { .. }))); } +#[cfg(feature = "jpegls")] #[test] fn a_restart_marker_after_a_scan_of_one_interval_is_an_error() { // With an interval of 3 lines the 5x3 scan is one interval, which no restart marker follows. @@ -489,6 +490,7 @@ fn a_restart_marker_after_a_scan_of_one_interval_is_an_error() { assert!(decode(&bytes).is_err()); } +#[cfg(feature = "jpegls")] #[test] fn a_restart_marker_after_a_comment_is_an_error_while_an_interval_is_set() { let (img, plain) = jpeg_ls_file(); diff --git a/crates/image-codecs/tests/it/jp2_feature.rs b/crates/image-codecs/tests/it/jp2_feature.rs index 9d75731c5d..c3e47c7a6f 100644 --- a/crates/image-codecs/tests/it/jp2_feature.rs +++ b/crates/image-codecs/tests/it/jp2_feature.rs @@ -1,4 +1,4 @@ -//! JPEG 2000 decode is opt-in: without the `jp2` feature a JP2 file is detected and refused with a +//! JPEG 2000 decode is default-on: without the `jp2` feature a JP2 file is detected and refused with a //! named reason rather than decoded, so a crate that only reads SVG keeps no JPEG 2000 decoder. use craft_image_codecs::*; diff --git a/crates/svg/Cargo.toml b/crates/svg/Cargo.toml index e8367fd8aa..11be578ed3 100644 --- a/crates/svg/Cargo.toml +++ b/crates/svg/Cargo.toml @@ -21,7 +21,8 @@ reads = [ craft-xml = { workspace = true } quick-xml = { version = "0.41", default-features = false } # Probing and bounding raster images embedded in a parsed tree (`tree`). -craft-image-codecs = { workspace = true, optional = true } +# SVG embeds only PNG, JPEG, GIF and WebP; don't re-enable every raster codec downstream. +craft-image-codecs = { path = "../image-codecs", default-features = false, features = ["webp"], optional = true } # SVGZ (gzip), pure-Rust backend. flate2 = { version = "1", default-features = false, features = ["rust_backend"] } kurbo = { workspace = true }