<强> python多图片合并pdf 强>
<>强起因强>
一个做美工的朋友需要将多个图片jpg, png合并起来,PS操作太慢了所以用了python进行完成这个任务
<强>代码强>
#?usr/bin/env python # - * -编码:utf - 8 - * py # @File: 2. # @Author: huifer # @Date: 2018/12/20 从公益诉讼导入图像 进口操作系统 def rea (pdf_name): file_list=os.listdir (“。”) pic_name=[] im_list=[] 在file_list x: 如果“jpg”或“png”x或jpeg的x: pic_name.append (x) pic_name.sort () new_pic=[] 在pic_name x: 如果“jpg”x: new_pic.append (x) 在pic_name x: 如果“png”x: new_pic.append (x) 打印(hec, new_pic) im1=Image.open (new_pic [0]) new_pic.pop (0) 因为我在new_pic: img=Image.open(我) # im_list.append (Image.open(我)) 如果img。模式==癛GBA”: img=img.convert (RGB) im_list.append (img) 其他: im_list.append (img) im1。保存(pdf_name, PDF,决议=100.0,save_all=True, append_images=im_list) 打印(“输出文件名称:“,pdf_name) if __name__==癬_main__”: tttt=" " _____ _____ _____ _____ _____专攻 | __ \ _ _/___ | | _ _/_ \ \ | | __年__ \ | | | | __)| | | | | | | | | | | | | __)| | | | | __ | ___/| | | | | | | | | | | ___/| | | | | __ | | | _ | | | | | | | _ | | | | | | _ | | | | _ | | _____、_____ | | _ __/| | \ _ | | _____/| _ | ”“” 打印(tttt) 打印(“合成”) pdf_name=输入(“请输入合成PDF文件名称:") 如果”。在pdf_name pdf”: rea (pdf_name=pdf_name) 其他: rea (pdf_name=" {} . pdf”.format (pdf_name)) 输入(“按任意键结束”)
合成后
<强>总结强>
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接