Reputation: 1
I have created an app that runs with PyGame, which loads a page of a PDF, creates a Pixmap with getPixmap and saves into a jpg file. Then, the image is displayed with pygame.image.load().
The program works perfectly fine, but it requires to save a .jpg file in the folder, which substitutes and therefore deletes the previous .jpg file. When converting it into an exe and distributing the program, the users get a security message error, saying that the program does not have the permission to delete the .jpg file.
How could I skip the part of saving the photo in the folder, and directly showing from the PDF into pygame?
I think it can be done by creating a file-like object with Bitmap.IO(), but I don't know how to use it. I'm relatively new in python, so I would appreciate if you could write the lines of code you would use.
zoom = 2
doc = fitz.open(pdf_path)
mat = fitz.Matrix(zoom, zoom)
page = doc.loadPage(photo_num)
pix = page.getPixmap(matrix = mat)
photo_output = "photo.jpg"
pix.writePNG(photo_output)
load_photo = pygame.image.load(photo_output)
Upvotes: 0
Views: 568