Fix handling of CMYK pages in PageImage conversion

This commit is contained in:
Jeremy Singer-Vine
2022-07-20 12:16:36 -04:00
parent c20c23afec
commit 28330da9c3
2 changed files with 13 additions and 2 deletions
+6
View File
@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/).
## [0.7.4] - [unreleased]
### Fixed
- Fix `PageImage` conversions for PDFs with `cmyk` colorspaces; convert them to `rgb` earlier in the process.
## [0.7.3] - 2022-07-18
### Fixed
+7 -2
View File
@@ -51,10 +51,15 @@ def get_page_image(stream: BufferedReader, page_no: int, resolution: int) -> Wan
def postprocess(img: WandImage) -> WandImage:
return WandImage(image=img.sequence[page_no])
with WandImage(resolution=resolution, filename=filename, file=file) as img_init:
with WandImage(
resolution=resolution, filename=filename, file=file, colorspace="rgb"
) as img_init:
img = postprocess(img_init)
with WandImage(
width=img.width, height=img.height, background=WandColor("white")
width=img.width,
height=img.height,
background=WandColor("white"),
colorspace="rgb",
) as bg:
bg.composite(img, 0, 0)
im = PIL.Image.open(BytesIO(bg.make_blob("png")))