mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-24 20:51:16 +03:00 
			
		
		
		
	Round position in pad()
This commit is contained in:
		
							parent
							
								
									df4bb34600
								
							
						
					
					
						commit
						f9d3ee0f48
					
				|  | @ -140,6 +140,15 @@ def test_pad(): | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def test_pad_round(): | ||||||
|  |     im = Image.new("1", (1, 1), 1) | ||||||
|  |     new_im = ImageOps.pad(im, (4, 1)) | ||||||
|  |     assert new_im.load()[2, 0] == 1 | ||||||
|  | 
 | ||||||
|  |     new_im = ImageOps.pad(im, (1, 4)) | ||||||
|  |     assert new_im.load()[0, 2] == 1 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def test_pil163(): | def test_pil163(): | ||||||
|     # Division by zero in equalize if < 255 pixels in image (@PIL163) |     # Division by zero in equalize if < 255 pixels in image (@PIL163) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -292,10 +292,10 @@ def pad(image, size, method=Image.Resampling.BICUBIC, color=None, centering=(0.5 | ||||||
|     else: |     else: | ||||||
|         out = Image.new(image.mode, size, color) |         out = Image.new(image.mode, size, color) | ||||||
|         if resized.width != size[0]: |         if resized.width != size[0]: | ||||||
|             x = int((size[0] - resized.width) * max(0, min(centering[0], 1))) |             x = round((size[0] - resized.width) * max(0, min(centering[0], 1))) | ||||||
|             out.paste(resized, (x, 0)) |             out.paste(resized, (x, 0)) | ||||||
|         else: |         else: | ||||||
|             y = int((size[1] - resized.height) * max(0, min(centering[1], 1))) |             y = round((size[1] - resized.height) * max(0, min(centering[1], 1))) | ||||||
|             out.paste(resized, (0, y)) |             out.paste(resized, (0, y)) | ||||||
|     return out |     return out | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user