(self, img: Image.Image)
| 17 | self.bg_color = tuple(int(x*255) for x in background_color) |
| 18 | |
| 19 | def __call__(self, img: Image.Image): |
| 20 | width, height = img.size |
| 21 | if width == height: |
| 22 | return img |
| 23 | elif width > height: |
| 24 | result = Image.new(img.mode, (width, width), self.bg_color) |
| 25 | result.paste(img, (0, (width - height) // 2)) |
| 26 | return result |
| 27 | else: |
| 28 | result = Image.new(img.mode, (height, height), self.bg_color) |
| 29 | result.paste(img, ((height - width) // 2, 0)) |
| 30 | return result |
| 31 | |
| 32 | def __repr__(self) -> str: |
| 33 | format_string = self.__class__.__name__ + f"(bg_color={self.bg_color})" |
nothing calls this directly
no outgoing calls
no test coverage detected