1. 程式人生 > >用python完成程式設計師的表白

用python完成程式設計師的表白

程式設計師的520怎麼表白

照片牆

依賴:
pip install Image clize

使用:
python picture_wall.py --help

Usage: ./picture_wall.py [OPTIONS] [text...]

生成照片牆

Arguments:
  text...                 Text of picture wall, if not defined this will generage a rectangle picture wall

Options:
  -s, --font-size=INT     font size of
a clear value (default: 20) -e, --edge-len=INT sub picture's egde length (default: 50) -w, --wall-width=INT picture number of rectangle width (default: 20) -l, --wall-length=INT picture number of rectangle length (default: 10) -d, --pic-dir=STR picture's path (default: ./img) -o, --out-dir=STR output dir (default
: ./out) -p, --font-path=STR font path (default: ./demo.ttf) Other actions: -h, --help Show the help

for example:

./picture_wall.py I Love U -s 30 -e 10
這裡寫圖片描述

./picture_wall.py 我愛你 -s 30 -e 10
這裡寫圖片描述

TODO

  • 子照片的處理方式有待提升,目前採用的只是根據字型畫素透明度控制透明度,還可以抽象出來讓使用者選擇控制方式~比如:
    • 根據字型畫素透明度控制子圖尺寸
    • 根據字型畫素透明度控制子圖形狀
    • 根據字型畫素透明度控制子圖顏色亮度
    • 或者直接採用圓形裁剪子圖

愛心情書

依賴:
pip install jieba numpy pandas matplotlib wordcloud scipy wordcloud

使用:
python heart_cloud_word.py --help

Usage: ./heart_cloud_word.py [OPTIONS] [par...]

生成文字雲

Arguments:
  par...

Options:
  -t, --text-file=STR   text file that contain all you word (default: ./data/love_letter.txt)
  -s, --stop-file=STR   the stop word which can't be considered (default: ./data/stopwords.txt)
  -c, --color-img=STR   the color map img (default: ./data/pink.jpg)
  -m, --mask-file=STR   the mask img for the word
  -o, --out-file=STR    output file path which should with sufix of png/jpg... (default: ./out/word_cloud.png)
  -p, --font-path=STR   font path (default: ./demo.ttf)

Other actions:
  -h, --help            Show the help

for example:

./heart_cloud_word.py
這裡寫圖片描述

TODO

  • 增加背景照片和註釋文字形成最終類似下圖的效果
    這裡寫圖片描述

如果對你有幫助~