mirror of
https://github.com/pretix/pretix.git
synced 2026-08-26 13:14:40 +00:00
Invoice rendering: Remove logos from transparency
This commit is contained in:
@@ -388,6 +388,11 @@ class ClassicInvoiceRenderer(BaseReportlabInvoiceRenderer):
|
|||||||
except:
|
except:
|
||||||
logger.exception("Can not resize image")
|
logger.exception("Can not resize image")
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
ir.remove_transparency()
|
||||||
|
except:
|
||||||
|
logger.exception("Can not remove transparency from logo")
|
||||||
|
pass
|
||||||
canvas.drawImage(ir,
|
canvas.drawImage(ir,
|
||||||
self.logo_left,
|
self.logo_left,
|
||||||
self.pagesize[1] - self.logo_height - self.logo_top,
|
self.pagesize[1] - self.logo_height - self.logo_top,
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ class ThumbnailingImageReader(ImageReader):
|
|||||||
self._data = None
|
self._data = None
|
||||||
return width, height
|
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):
|
def _jpeg_fh(self):
|
||||||
# Bypass a reportlab-internal optimization that falls back to the original
|
# 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
|
# file handle if the file is a JPEG, and therefore does not respect the
|
||||||
|
|||||||
Reference in New Issue
Block a user