Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf file transform to image have a black block #3624

Closed
Agoin-max opened this issue Jun 26, 2024 · 3 comments
Closed

Pdf file transform to image have a black block #3624

Agoin-max opened this issue Jun 26, 2024 · 3 comments
Labels
fix developed release schedule to be determined Fixed in next release upstream bug bug outside this package

Comments

@Agoin-max
Copy link

Agoin-max commented Jun 26, 2024

Description of the bug

Pdf file transform to image have a black block
89b59dbfae5e4d1d92596418e9585a10.pdf

How to reproduce the bug

def pdf2png_with_pymupdf(pdf_data: Union[bytes, str], matrix: int = 2):
    """转换图片."""
    images: List[Image.Image] = []
    path = tempfile.mkdtemp()
    path_ = Path(path)

    try:
        if isinstance(pdf_data, bytes):
            pdf_path = str(path_.joinpath("mypdf.pdf"))
            with open(pdf_path, "wb") as fs:
                fs.write(pdf_data)
        else:
            pdf_path = pdf_data

        doc = fitz.open(pdf_path)
        for page_index in range(len(doc)):
            page = doc.load_page(page_index)
            pix = page.get_pixmap(matrix=fitz.Matrix(matrix, matrix))  # type: ignore
            img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples)  # type: ignore
            images.append(img)
        doc.close()
    finally:
        delete_temp_directory(path)
   this is my code

PyMuPDF version

1.24.6

Operating system

Windows

Python version

3.9

@JorjMcKie
Copy link
Collaborator

This is an issue in MuPDF.
Created an item in its tracker: https://bugs.ghostscript.com/show_bug.cgi?id=707845

@JorjMcKie JorjMcKie added upstream bug bug outside this package labels Jun 26, 2024
@sebras
Copy link
Contributor

sebras commented Sep 27, 2024

@JorjMcKie According to the upstream bug report this has been fixed, and thus this bug could be marked "fix developed"?

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix developed release schedule to be determined Fixed in next release upstream bug bug outside this package
Projects
None yet
Development

No branches or pull requests

4 participants