From c0aaf548161a2ef16147b2dfe1916c789cae962d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 19 Sep 2022 12:41:20 +1000 Subject: [PATCH] Removed unnecessary palette copy --- src/PIL/ImageOps.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index b08fc69ae..361048d7a 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -291,9 +291,8 @@ def pad(image, size, method=Image.Resampling.BICUBIC, color=None, centering=(0.5 out = resized else: out = Image.new(image.mode, size, color) - palette = image.palette.copy() - if palette: - out.putpalette(palette) + if resized.palette: + out.putpalette(resized.palette) if resized.width != size[0]: x = int((size[0] - resized.width) * max(0, min(centering[0], 1))) out.paste(resized, (x, 0))