基于python生成手写的笔记
生活随笔
收集整理的這篇文章主要介紹了
基于python生成手写的笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
博客并沒有其他網站的號,未經允許不得私自轉發
覺得不錯,可以關注公眾號:小白學習教程,
需要第三方庫
PIL,Image,ImageFont,python-docx,handright
from PIL import Image, ImageFont import docx from handright import Template, handwritetext="" file = docx.Document(r".\筆記.docx") ##word路徑for pare in file.paragraphs:text =text +'\n' + str(pare.text)print(text)template = Template(background = Image.open(r".\22.jpg"), ## 需要手動拍攝一張圖片font_size=40,font=ImageFont.truetype(r".\MILanProVF-Thin.ttf"), ##字體line_spacing=50, fill=0,left_margin=100,top_margin=100,right_margin=100,bottom_margin=100,word_spacing=2,line_spacing_sigma=0,font_size_sigma=2,word_spacing_sigma=2,end_chars=", :",perturb_x_sigma=4,perturb_y_sigma=4,perturb_theta_sigma=0.05, ) image =handwrite(text,template) for i ,im in enumerate(image):assert isinstance(im,Image.Image)im.save("./1.jpg".format(i)) ## 生成的圖片生成的圖片如下,字跡可以改
總結
以上是生活随笔為你收集整理的基于python生成手写的笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工作384-jq的立即执行函数
- 下一篇: NanoPC-T4 RK3399和PC有