Keep SVG raster validation from enabling unused codecs

This commit is contained in:
Codex committed 2026-11-29 19:43:00 +01:00
1 parent 17a339cd8f
commit 1cfe12fa7e
5 files changed
+10 -6

No files matched your search

+3 -2
View File
@@ -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.
+2 -2
View File
@@ -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")]
@@ -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();
+1 -1
View File
@@ -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::*;
+2 -1
View File
@@ -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 }