Closed
Description
Please provide all mandatory information!
Describe the bug (mandatory)
I have a 50% transparent white image in pdf file. I want to use Page.get_pixmap(alpha=True)
to render the page as pixmap, convert pixmap to pillow image, and paste it on another image (as watermark, for example). But the pixmap I get is gray image.
To Reproduce (mandatory)
code snippet:
import fitz
from PIL import Image
doc=fitz.open('alpha.pdf')
page=doc[0]
pix=page.get_pixmap(alpha=True)
img=Image.frombytes('RGBA', [pix.width, pix.height], pix.samples)
img.show()
img.save('alpha.tiff')
example pdf:
alpha.pdf
Expected behavior (optional)
white image with transparency
Your configuration (mandatory)
- Operating system, potentially version and bitness
- Python version, bitness
- PyMuPDF version, installation method (wheel or generated from source).
3.11.3 (main, Jun 5 2023, 09:32:32) [GCC 13.1.1 20230429]
linux
PyMuPDF 1.22.5: Python bindings for the MuPDF 1.22.2 library.
Version date: 2023-06-21 00:00:01.
Built for Python 3.11 on linux (64-bit).
PyMuPDF generated from source
Additional context (optional)
If I save pixmap with pix.save(), the saved image looks fine
Metadata
Metadata
Assignees
Labels
No labels