PyMuPDF
PyMuPDF copied to clipboard
PDF's 45º lines dissapearing in png conversion
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:
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()
PyMuPDF version
1.23.22
Operating system
Windows
Python version
3.11
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.
@JorjMcKie thank you for your help!
The MuPDF team has already developed a fix, which will be integrated in one of our next PyMuPDF releases.
Fixed in 1.24.0.