File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1+ use image:: { ColorType , DynamicImage } ;
12use walkdir:: WalkDir ;
23
34#[ test]
@@ -10,7 +11,7 @@ fn test_decoding() {
1011 continue ;
1112 }
1213
13- let img = image:: open ( entry. path ( ) ) . unwrap ( ) ;
14+ let img = to_png_compatible_color_type ( image:: open ( entry. path ( ) ) . unwrap ( ) ) ;
1415 let reference = image:: open ( entry. path ( ) . with_extension ( "png" ) ) . unwrap ( ) ;
1516
1617 assert_eq ! (
@@ -21,3 +22,12 @@ fn test_decoding() {
2122 ) ;
2223 }
2324}
25+
26+ /// PNG doesn't support 32-bit float color types, so convert them to 16-bit.
27+ fn to_png_compatible_color_type ( image : DynamicImage ) -> DynamicImage {
28+ match image. color ( ) {
29+ ColorType :: Rgb32F => image. to_rgb16 ( ) . into ( ) ,
30+ ColorType :: Rgba32F => image. to_rgba16 ( ) . into ( ) ,
31+ _ => image,
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments