-
-
Save cosmicqbit/2dc504e6d2f744fef6dc556e3a29fed4 to your computer and use it in GitHub Desktop.
Batch Convert Images to PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from email.mime import base | |
from PIL import Image | |
import os | |
image_list = [] | |
files = os.listdir() | |
image_files = [] | |
for i in range(len(files)): | |
if files[i].endswith(".png"): | |
image_files.append(files[i]) | |
for i in range(len(image_files)): | |
image = Image.open(image_files[i]).convert('RGB') | |
image_list.append(image) | |
if i == 0: | |
image_list.pop() | |
base_img = image | |
base_img.save('compiled-by-li.pdf', save_all=True, append_images=image_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
pip install PIL
Run
python run.py