How do I append a file extension to a variable?

I wrote a python application that converts images to PDF's using PIL. The method below takes all images in a given directory, converts them to RGB, then is supposed to save all the images as one *.pdf file. However, I'm unable to figure out how to provide the extension .pdf to the file output.

Concatenating does not work, I get error:

"Unknown file extension: {}.format(ext))

def multi_convert(file_path: str):
    for path in Path(file_path).iterdir():
        path = Image.open(path)
        path.convert('RGB')
    extension = 'file.pdf'
    final_file = file_path + extension
    path.save(final_file, save_all=True, append_images=path)


from Recent Questions - Stack Overflow https://ift.tt/2Vd6xuh
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation