test(trace): keep the image crate's JPEG encoder for the block-artifact fixture

a_jpegs_blocks_are_not_traced_as_steps measures how many traced edges land
on JPEG block boundaries, which depends on the encoder's artifacts. With the
craft-image-codecs encoder 18 of 40 segments sit on block edges; with the
original encoder and the new shared decoder the test passes unchanged, so
the trace itself is unaffected. image stays a dev-dependency only.
This commit is contained in:
FredApps
2026-11-15 15:48:44 +01:00
parent c9cad8d017
commit 845e68008b
3 changed files with 9 additions and 4 deletions
Generated
+1
View File
@@ -7034,6 +7034,7 @@ name = "vectorcraft-trace"
version = "0.24.1"
dependencies = [
"craft-image-codecs",
"image",
"kurbo 0.13.1",
"serde",
"serde_json",
+2
View File
@@ -17,3 +17,5 @@ thiserror = { workspace = true }
[dev-dependencies]
serde_json = { workspace = true }
# Test fixtures only: the JPEG-block test needs the block artifacts of the encoder it was tuned on.
image = { workspace = true }
+6 -4
View File
@@ -2174,12 +2174,14 @@ fn small_accents_of_other_colors_leave_a_tinted_photo_continuous_tone() {
}
}
/// `img` saved as a JPEG of `quality` and read back.
/// `img` saved as a JPEG of `quality` and read back. The `image` crate's encoder stays the fixture:
/// `a_jpegs_blocks_are_not_traced_as_steps` measures block artifacts, which differ by encoder.
fn through_jpeg(img: &Raster, quality: u8) -> Raster {
let rgb: Vec<u8> = img.rgba.chunks(4).flat_map(|p| [p[0], p[1], p[2]]).collect();
let encoded = craft_image_codecs::Image::from_u8(img.width, img.height, craft_image_codecs::ChannelLayout::Rgb, rgb).unwrap();
let opts = craft_image_codecs::EncodeOptions { jpeg_quality: quality, ..Default::default() };
let bytes = craft_image_codecs::encode(&encoded, craft_image_codecs::Format::Jpeg, &opts).unwrap();
let mut bytes = vec![];
image::codecs::jpeg::JpegEncoder::new_with_quality(&mut bytes, quality)
.encode(&rgb, img.width, img.height, image::ExtendedColorType::Rgb8)
.unwrap();
Raster::decode(&bytes).unwrap()
}