mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Put palette into the new pad image
This commit is contained in:
		
							parent
							
								
									355a0f73e9
								
							
						
					
					
						commit
						d80aa74da4
					
				| 
						 | 
					@ -291,6 +291,9 @@ def pad(image, size, method=Image.Resampling.BICUBIC, color=None, centering=(0.5
 | 
				
			||||||
        out = resized
 | 
					        out = resized
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        out = Image.new(image.mode, size, color)
 | 
					        out = Image.new(image.mode, size, color)
 | 
				
			||||||
 | 
					        palette = image.palette.copy()
 | 
				
			||||||
 | 
					        if palette:
 | 
				
			||||||
 | 
					            out.putpalette(palette.palette)
 | 
				
			||||||
        if resized.width != size[0]:
 | 
					        if resized.width != size[0]:
 | 
				
			||||||
            x = int((size[0] - resized.width) * max(0, min(centering[0], 1)))
 | 
					            x = int((size[0] - resized.width) * max(0, min(centering[0], 1)))
 | 
				
			||||||
            out.paste(resized, (x, 0))
 | 
					            out.paste(resized, (x, 0))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user