mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-15 21:57:04 +00:00
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:
Generated
+1
@@ -7034,6 +7034,7 @@ name = "vectorcraft-trace"
|
||||
version = "0.24.1"
|
||||
dependencies = [
|
||||
"craft-image-codecs",
|
||||
"image",
|
||||
"kurbo 0.13.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user