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's 45º lines dissapearing in png conversion #3172

Closed
gabrielbeneli-missler opened this issue Feb 16, 2024 · 4 comments
Closed

PDF's 45º lines dissapearing in png conversion #3172

gabrielbeneli-missler opened this issue Feb 16, 2024 · 4 comments
Labels
fix developed release schedule to be determined Fixed in next release upstream bug bug outside this package

Comments

@gabrielbeneli-missler
Copy link

Description of the bug

Hello,

I'm using the following function to convert PDF files into PNG:

        pix = page.get_pixmap(matrix=fitz.Matrix(40, 40),alpha=False,colorspace=fitz.csGRAY)
        pix.save(image_path, "png")

The conversion occurs as expected but every 45º line dissapears:

image

How to reproduce the bug

Using this function to convert the attached PDF.

def convert_pdf_to_images(pdf_path, output_folder):
    """
    Convert a multiple page PDF into single PNG files

    - pdf_path (str): A string containning the path for the PDF to be converted.
    - output_folder (str): A string containning the path for the folder to dump the images.

    """
    doc = fitz.open(pdf_path)

    for page_num in range(len(doc)):
        page = doc[page_num]
        pagenumiter = ('00000' + str(page_num + 1))[-5:]
        image_name = f"page_{pagenumiter}.png"
        image_path = f"{output_folder}/{image_name}"

        # Convert the PDF page to an image
        pix = page.get_pixmap(matrix=fitz.Matrix(40, 40),alpha=False,colorspace=fitz.csGRAY)
        pix.save(image_path, "png")

        print(f"Converted page {page_num + 1} to {image_path}")

    doc.close()

image

test.pdf

PyMuPDF version

1.23.22

Operating system

Windows

Python version

3.11

@JorjMcKie JorjMcKie added the upstream bug bug outside this package label Feb 16, 2024
@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Feb 16, 2024

This is an issue in the base library. I will submit a bug report in their system.

Here is the issue reference at MuPDF's system: https://bugs.ghostscript.com/show_bug.cgi?id=707590.

@gabrielbeneli-missler
Copy link
Author

@JorjMcKie thank you for your help!

@JorjMcKie JorjMcKie added the fix developed release schedule to be determined label Feb 17, 2024
@JorjMcKie
Copy link
Collaborator

The MuPDF team has already developed a fix, which will be integrated in one of our next PyMuPDF releases.

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.0.

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

3 participants