mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 23:47:27 +03:00 
			
		
		
		
	Merge pull request #2092 from wiredfool/bigendian-fixes
Test fix for bigendian machines
This commit is contained in:
		
						commit
						03db2263e3
					
				|  | @ -463,13 +463,20 @@ class TestFileTiff(PillowTestCase): | |||
|         im2 = hopper() | ||||
|         self.assert_image_similar(im, im2, 5) | ||||
| 
 | ||||
|     def test_open_tiff_uint16(self): | ||||
|     def test_roundtrip_tiff_uint16(self): | ||||
|         # Test an image of all '0' values | ||||
|         pixel_value = 0x1234 | ||||
|         infile = "Tests/images/uint16_1_4660.tif" | ||||
|         im = Image.open(infile) | ||||
|         self.assertEqual(im.getpixel((0, 0)), pixel_value) | ||||
| 
 | ||||
|         tmpfile = self.tempfile("temp.tif") | ||||
|         im.save(tmpfile) | ||||
|          | ||||
|         reloaded = Image.open(tmpfile) | ||||
|          | ||||
|         self.assert_image_equal(im, reloaded) | ||||
|          | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| from __future__ import print_function | ||||
| import sys | ||||
| from helper import unittest, PillowTestCase, hopper | ||||
| import sys | ||||
| 
 | ||||
| from PIL import Image | ||||
| 
 | ||||
|  | @ -137,19 +138,14 @@ class TestNumpy(PillowTestCase): | |||
|         numpy.testing.assert_array_equal(arr, arr_back) | ||||
| 
 | ||||
|     def test_save_tiff_uint16(self): | ||||
|         ''' | ||||
|         Open a single-channel uint16 greyscale image and verify that it can be saved without | ||||
|         losing precision. | ||||
|         ''' | ||||
|         tmpfile = self.tempfile("temp.tif") | ||||
|         # Tests that we're getting the pixel value in the right byte order.  | ||||
|         pixel_value = 0x1234 | ||||
|         filename = "Tests/images/uint16_1_4660.tif" | ||||
|         a = numpy.array([pixel_value] * TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1], dtype=numpy.uint16) | ||||
|         a.shape = TEST_IMAGE_SIZE | ||||
|         Image.fromarray(a).save(tmpfile) | ||||
|         im_test = Image.open(tmpfile) | ||||
|         im_good = Image.open(filename) | ||||
|         self.assert_image_equal(im_good, im_test) | ||||
|         img = Image.fromarray(a) | ||||
| 
 | ||||
|         img_px = img.load() | ||||
|         self.assertEqual(img_px[0,0], pixel_value) | ||||
| 
 | ||||
|     @unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy") | ||||
|     def test_to_array(self): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user