diff --git a/imageflow_core/src/codecs/pngquant.rs b/imageflow_core/src/codecs/pngquant.rs index c56982463..7cd3a2d3c 100644 --- a/imageflow_core/src/codecs/pngquant.rs +++ b/imageflow_core/src/codecs/pngquant.rs @@ -56,6 +56,11 @@ impl Encoder for PngquantEncoder { let mut bitmap = bitmaps.try_borrow_mut(bitmap_key) .map_err(|e| e.at(here!()))?; + { + let mut bitmap_bgra = unsafe { bitmap.get_window_u8().unwrap().to_bitmap_bgra()? }; + bitmap_bgra.normalize_alpha().map_err(|e| e.at(here!()))?; + } + unsafe { let (vec,w,h) = bitmap.get_window_u8() .ok_or_else(|| nerror!(ErrorKind::InvalidBitmapType))? diff --git a/imageflow_core/tests/visuals.rs b/imageflow_core/tests/visuals.rs index f5ffe709b..73eba79cb 100644 --- a/imageflow_core/tests/visuals.rs +++ b/imageflow_core/tests/visuals.rs @@ -92,12 +92,12 @@ fn test_transparent_png_to_png() { #[test] fn test_problematic_png_lossy() { compare_encoded( - Some(IoTestEnum::Url("https://imageflow-resources.s3.us-west-2.amazonaws.com/test_inputs/png_turns_empty.png".to_owned())), + Some(IoTestEnum::Url("https://imageflow-resources.s3.us-west-2.amazonaws.com/test_inputs/png_turns_empty_2.png".to_owned())), "test_problematic_png_lossy", POPULATE_CHECKSUMS, DEBUG_GRAPH, Constraints { - similarity: Similarity::AllowOffByOneBytesCount(100), + similarity: Similarity::AllowDssimMatch(0.0, 0.002), max_file_size: None }, vec![ diff --git a/imageflow_core/tests/visuals/checksums.json b/imageflow_core/tests/visuals/checksums.json index 294081d92..2c1c2070b 100644 --- a/imageflow_core/tests/visuals/checksums.json +++ b/imageflow_core/tests/visuals/checksums.json @@ -78,7 +78,7 @@ "test_branching_crop_whitespace_gradient_output_1": "01864661ED8AB31EF.png", "test_branching_crop_whitespace_gradient_output_2": "0B3D16EB972FE0DBB.png", "test_negatives_in_command_string": "0BA85F7DC751DD69E_0726847C75419A20C", - "test_problematic_png_lossy": "0E5E63543D35A149D.png", + "test_problematic_png_lossy": "03B9493B2F3806A45.png", "test_rot_90_and_red_dot": "0176FBE641002F3ED_0AE4839D1D9B04C57", "test_rot_90_and_red_dot_command_string": "0C790C6600AFBBADA_0AE4839D1D9B04C57", "test_round_corners_command_string": "05218274046A5989B_0BF80F0AE71CD9A63",