728x90
반응형
import os
from PIL import Image
directory = "./images"
image_files = natsorted([filename for filename in os.listdir(directory) if filename.endswith('.jpg')])
images = [Image.open(directory + '/' + f) for f in image_files]
images[0].save("out.pdf", "PDF", resolution=100.0, save_all=True, append_images=images[1:])
# 1부터 저장해야지 안그러면 똑같은 페이지 하나 더 들어감
728x90
반응형
'사소한 Tip . 오류 해결법 > python' 카테고리의 다른 글
[python/pdf] PDF 수정(페이지 삭제, 병합)하기(PyPDF2) (0) | 2024.01.05 |
---|---|
[pandas / DataFrame] MultiIndex df.to_excel 저장 시 빈 행(row) 삭제하기 (0) | 2024.01.03 |
[PIL] 투명한 이미지 만들기(글자만 남기기) / transparent image / remove background (2) | 2023.10.11 |
[python] open() got an unexpected keyword argument 'encoding' / python 3.9 (0) | 2023.09.06 |
[python] 클래스 별 랜덤 컬러 정의 (0) | 2023.08.23 |