Skip to content
Discussion options

You must be logged in to vote

An image's transparency / opacity is a property of the image, and there is nothing in PDF that lets you display an image transparently if the image per se is not transparent.

There are ways however to add transparency (i.e., alpha channel) to an image in PyMuPDF, and also to set the single values of each transparency byte. Then insert the modified image.
This process incurs using the Pixmap class and roughly work along this snippet:

pix = fitz.Pixmap(<image>)  # could be some image file, or an image in memory
# check if it has an alpha channel, if not add one
if not pix.alpha:
    pix = fitz.Pixmap(pix, 1)  # alpha channel added
# number of pixels
pixel_count = pix.width * pix.height
# pr…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by allen0099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants