HuamingHuang / pic2text

A script to transform picture to text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pic2text 图片转文字

A script to transform picture to text, supporting Chinese
一个将图片转换成文字图的脚本,支持中文
刚学Python不久,代码不是特别简洁,因为要计算出灰度范围,导致循环了两次
为了支持中文,必须要使用中文字体
代码基本每一行都注释了
效果图: image

Dependencies 环境依赖

Python 2.7
PIL

How to use 如何使用

copy a font file to your directory and edit line 27:
拷贝一个字体文件到目录,然后修改代码27行中的字体名称:

  ft = ImageFont.truetype("msyhbd.ttf",fontSize)

edit last several lines of codes:
编辑最后几行代码:

    textList = ['撒','啊','呵','王','一']
    pic2Text('test.jpg',textList)

sort characters by Density
按照字母笔画密集程度排列

About 关于作者

不灭的小灯灯
Love programming,love designing
Mail:winterfeel@qq.com
Blog:www.winterfeel.com

About

A script to transform picture to text


Languages

Language:Python 100.0%