mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-29 23:17:49 +03:00 
			
		
		
		
	Merge pull request #5938 from radarhere/zero
Return an empty bytestring from tobytes() for an empty image
This commit is contained in:
		
						commit
						5908ccc5ae
					
				|  | @ -786,6 +786,11 @@ class TestImage: | ||||||
|                 34665: 196, |                 34665: 196, | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |     @pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0))) | ||||||
|  |     def test_zero_tobytes(self, size): | ||||||
|  |         im = Image.new("RGB", size) | ||||||
|  |         assert im.tobytes() == b"" | ||||||
|  | 
 | ||||||
|     def test_categories_deprecation(self): |     def test_categories_deprecation(self): | ||||||
|         with pytest.warns(DeprecationWarning): |         with pytest.warns(DeprecationWarning): | ||||||
|             assert hopper().category == 0 |             assert hopper().category == 0 | ||||||
|  |  | ||||||
|  | @ -716,6 +716,9 @@ class Image: | ||||||
| 
 | 
 | ||||||
|         self.load() |         self.load() | ||||||
| 
 | 
 | ||||||
|  |         if self.width == 0 or self.height == 0: | ||||||
|  |             return b"" | ||||||
|  | 
 | ||||||
|         # unpack data |         # unpack data | ||||||
|         e = _getencoder(self.mode, encoder_name, args) |         e = _getencoder(self.mode, encoder_name, args) | ||||||
|         e.setimage(self.im) |         e.setimage(self.im) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user