mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
Fix handling of CMYK pages in PageImage conversion
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")))
|
||||
|
||||
Reference in New Issue
Block a user