From d80aa74da45706ddce358130801a653830097581 Mon Sep 17 00:00:00 2001 From: Sitcebelly Date: Sun, 18 Sep 2022 21:14:52 +0300 Subject: [PATCH] Put palette into the new pad image --- src/PIL/ImageOps.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 0c3f900ca..9a2dd66c9 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -291,6 +291,9 @@ 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.palette) if resized.width != size[0]: x = int((size[0] - resized.width) * max(0, min(centering[0], 1))) out.paste(resized, (x, 0))