1010
1111import  rawpy 
1212import  rawpy .enhance 
13- import  imageio 
13+ import  imageio . v3   as   iio 
1414from  rawpy .enhance  import  _repair_bad_pixels_bayer2x2 ,\
1515    _repair_bad_pixels_generic , find_bad_pixels 
1616
@@ -52,48 +52,48 @@ def testFileOpenAndPostProcess():
5252    rgb  =  raw .postprocess (no_auto_bright = True , user_wb = raw .daylight_whitebalance )
5353    assert_array_equal (rgb .shape , [2844 , 4284 , 3 ])
5454    print_stats (rgb )
55-     save ('test_8daylight.tiff' , rgb )
55+     iio . imwrite ('test_8daylight.tiff' , rgb )
5656
5757    print ('daylight white balance multipliers:' , raw .daylight_whitebalance )
5858
5959    rgb  =  raw .postprocess (no_auto_bright = True , user_wb = raw .daylight_whitebalance )
6060    print_stats (rgb )
61-     save ('test_8daylight2.tiff' , rgb )
61+     iio . imwrite ('test_8daylight2.tiff' , rgb )
6262
6363    rgb  =  raw .postprocess (no_auto_bright = True , user_wb = raw .daylight_whitebalance ,
6464                          output_bps = 16 )
6565    print_stats (rgb )
66-     save ('test_16daylight.tiff' , rgb )
66+     iio . imwrite ('test_16daylight.tiff' , rgb )
6767
6868    # linear images are more useful for science (=no gamma correction) 
6969    # see http://www.mit.edu/~kimo/blog/linear.html 
7070    rgb  =  raw .postprocess (no_auto_bright = True , user_wb = raw .daylight_whitebalance ,
7171                          gamma = (1 ,1 ), output_bps = 16 )
7272    print_stats (rgb )
73-     save ('test_16daylight_linear.tiff' , rgb )
73+     iio . imwrite ('test_16daylight_linear.tiff' , rgb )
7474
7575def  testFoveonFileOpenAndPostProcess ():
7676    raw  =  rawpy .imread (raw4TestPath )
7777
7878    assert_array_equal (raw .raw_image .shape , [1531 , 2304 , 3 ])
79-     save ('test_foveon_raw.tiff' , raw .raw_image )
79+     iio . imwrite ('test_foveon_raw.tiff' , raw .raw_image )
8080
8181    rgb  =  raw .postprocess ()
8282    assert_array_equal (rgb .shape , [1510 , 2266 , 3 ])
8383    print_stats (rgb )
84-     save ('test_foveon.tiff' , rgb )
84+     iio . imwrite ('test_foveon.tiff' , rgb )
8585
8686def  testSRawFileOpenAndPostProcess ():
8787    raw  =  rawpy .imread (raw5TestPath )
8888
8989    assert_array_equal (raw .raw_image .shape , [1296 , 1944 , 4 ])
9090    assert_equal (raw .raw_image [:,:,3 ].max (), 0 )
91-     save ('test_sraw_raw.tiff' , raw .raw_image [:,:,:3 ])
91+     iio . imwrite ('test_sraw_raw.tiff' , raw .raw_image [:,:,:3 ])
9292
9393    rgb  =  raw .postprocess ()
9494    assert_array_equal (rgb .shape , [1296 , 1944 , 3 ])
9595    print_stats (rgb )
96-     save ('test_sraw.tiff' , rgb )
96+     iio . imwrite ('test_sraw.tiff' , rgb )
9797
9898def  testFileOpenWithNonAsciiCharacters ():
9999    raw  =  rawpy .imread (raw6TestPath )
@@ -104,7 +104,7 @@ def testBufferOpen():
104104            assert_array_equal (raw .raw_image .shape , [2844 , 4288 ])
105105            rgb  =  raw .postprocess ()
106106    print_stats (rgb )
107-     save ('test_buffer.tiff' , rgb )
107+     iio . imwrite ('test_buffer.tiff' , rgb )
108108
109109def  testContextManager ():
110110    with  rawpy .imread (rawTestPath ) as  raw :
@@ -140,7 +140,7 @@ def testThumbExtractJPEG():
140140    with  rawpy .imread (rawTestPath ) as  raw :
141141        thumb  =  raw .extract_thumb ()
142142    assert  thumb .format  ==  rawpy .ThumbFormat .JPEG 
143-     img  =  imageio . v3 .imread (thumb .data )
143+     img  =  iio .imread (thumb .data )
144144    assert_array_equal (img .shape , [2832 , 4256 , 3 ])
145145
146146def  testThumbExtractBitmap ():
@@ -278,16 +278,6 @@ def testCorruptFile():
278278    with  pytest .raises (rawpy .LibRawDataError ):
279279        im .extract_thumb ()
280280
281- def  save (path , im ):
282-     # both imageio and skimage currently save uint16 images with 180deg rotation 
283-     # as they both use freeimage and this has some weird internal formats 
284-     # see https://github.com/scikit-image/scikit-image/issues/1101 
285-     # and https://github.com/imageio/imageio/issues/3 
286-     from  packaging .version  import  Version 
287-     if  im .dtype  ==  np .uint16  and  Version (imageio .__version__ ) <=  Version ('0.5.1' ):
288-         im  =  im [::- 1 ,::- 1 ]
289-     imageio .v3 .imwrite (path , im )
290- 
291281def  print_stats (rgb ):
292282    print (rgb .dtype , 
293283          np .min (rgb , axis = (0 ,1 )), np .max (rgb , axis = (0 ,1 )), # range for each channel 
0 commit comments