Invoice rendering: Remove transparency from logos (Z#23179391) (#4762)

* Invoice rendering: Remove logos from transparency

* Add comment
This commit is contained in:
Raphael Michel
2025-01-21 15:03:43 +01:00
committed by GitHub
parent 1635118772
commit 045edc7cec
2 changed files with 15 additions and 0 deletions

View File

@@ -39,6 +39,12 @@ class ThumbnailingImageReader(ImageReader):
self._data = None
return width, height
def remove_transparency(self, background_color="WHITE"):
if "A" in self._image.mode:
new_image = Image.new("RGBA", self._image.size, background_color)
new_image.paste(self._image, mask=self._image)
self._image = new_image.convert("RGB")
def _jpeg_fh(self):
# Bypass a reportlab-internal optimization that falls back to the original
# file handle if the file is a JPEG, and therefore does not respect the