Code: Alles auswählen
Traceback (most recent call last):
File "main.py", line 5, in <module>
presentation.convert("/home/felix/Schreibtisch/PythonTest/", "kickoff18.pdf", "/home/felix/Schreibtisch/PythonTest/", "neuerOrdner")
File "/home/felix/Schreibtisch/PythonTest/model/presentation.py", line 16, in convert
pdf = wa(filename = path + filename, resolution=300)
File "/usr/lib/python2.7/dist-packages/wand/image.py", line 2744, in __init__
self.read(filename=filename, resolution=resolution)
File "/usr/lib/python2.7/dist-packages/wand/image.py", line 2822, in read
self.raise_exception()
File "/usr/lib/python2.7/dist-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.PolicyError: not authorized `/home/felix/Schreibtisch/PythonTest/kickoff18.pdf' @ error/constitute.c/ReadImage/412
Exception TypeError: TypeError("object of type 'NoneType' has no len()",) in <bound method Image.__del__ of <wand.image.Image: (empty)>> ignored
Code: Alles auswählen
from wand.image import Image as wa
import os, os.path
class Presentation:
"""Class that divides a PDF into individual images and converts them to jpg"""
def __init__(self):
"""Constructor of the class"""
pass
def convert(self, path, filename, folder_path, folder_name):
"""a method that takes a path and a PDF file, converts them to JPG, and then saves the individual images"""
folder = folder_path + folder_name
os.makedirs(folder)
pdf = wa(filename = path + filename, resolution=300)
pdf_images = pdf.convert("jpeg")
print("Bis hier")
os.chdir(folder)
page_number = 1
for img in pdf_images.sequence:
page = wa(image=img)
page.save(filename=str(page_number) + ".jpg")
page_number += 1
Code: Alles auswählen
from model.presentation import Presentation
if __name__ == "__main__":
presentation = Presentation()
presentation.convert("/home/felix/Schreibtisch/PythonTest/", "kickoff18.pdf", "/home/felix/Schreibtisch/PythonTest/", "neuerOrdner")
print("Run")
Es soll möglich sein einen neuen Ordner anzulegen, in welchem die Bilder der gesplitteten PDF liegen welche dann wiederrum ausgelesen werden sollen ob in der unteren rechten Ecke genug "weißer" Platz vorhanden ist um ein Video einzufügen, falls das der Fall ist soll das Video eingeblendet werden ansonsten soll das Bild der PDF unverändert dargestellt werden.
Vielen Dank im Vorraus
MfG Felix