利用Python给图片加文字

导入所需要的库

from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

添加字体(需要设置,可以不设置),加文字, 代码参考如下

from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

#打开底版图片
imageFile = "test.jpg"
tp=Image.open(imageFile)

# 在图片上添加文字
draw = ImageDraw.Draw(tp)
draw.text((100, 100),"测试文字",(255,255,0))

# 保存
tp.save("testOutput.png")

参考

[1] Python在图片上添加文字

CMakeLists Eigen FCPX GNU Gazebo Git Interest KDL Life Linux Matrix ODE ROS Ros UML Ubuntu VcXsrv algorithm algorithms axis-angle bode calibration chrome control cpp data_struct dots figure gdb latex launch life linux mac math matlab memory motor moveit operator optimal algorithm python robot robotics ros ros2 rtb simulation stl thread tools twist urdf velocity vim web work wsl
知识共享许可协议