代码
from PIL import Image
import os
def create_img_pdf(file_name,ouput_pdf):
page = Image.new('RGB', (2480, 3508), 'white')
image=Image.open(file_name)
i_w,i_h=image.size
if i_w>i_h:
i_n_w=2000
i_n_h=int(i_h*2000/i_w)
else:
i_n_h=3000
i_n_w=int(i_w*3000/i_h)
n_img=image.resize((i_n_w,i_n_h))
page.paste(n_img,(100,100))
page.save(ouput_pdf,"PDF", resolution=100.0)
create_img_pdf("./image/2.jpg","op.pdf")