mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 00:21:15 +03:00
Different colorspace depending of image format
This commit is contained in:
parent
7eff99018e
commit
86b32fa2c2
@ -202,12 +202,23 @@ class Context(pydyf.Stream):
|
||||
return self._parent
|
||||
|
||||
def add_image(self, pillow_image):
|
||||
image_mode = pillow_image.mode
|
||||
if image_mode in ('RGB', 'RGBA', 'P'):
|
||||
color_space = '/DeviceRGB'
|
||||
elif image_mode in ('1', 'L'):
|
||||
color_space = '/DeviceGray'
|
||||
elif image_mode == 'CMYK':
|
||||
color_space = '/DeviceCMYK'
|
||||
|
||||
if image_mode in ('RGBA', 'P'):
|
||||
pillow_image = pillow_image.convert('RGB')
|
||||
|
||||
extra = pydyf.Dictionary({
|
||||
'Type': '/XObject',
|
||||
'Subtype': '/Image',
|
||||
'Width': pillow_image.width,
|
||||
'Height': pillow_image.height,
|
||||
'ColorSpace': '/DeviceRGB',
|
||||
'ColorSpace': color_space,
|
||||
'BitsPerComponent': 8,
|
||||
'Filter': '/DCTDecode',
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user