# pic2Text **Repository Path**: winterfeel/pic2Text ## Basic Information - **Project Name**: pic2Text - **Description**: 一个将图片转换成文字图的脚本,支持中文 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-08-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pic2text 图片转文字 A script to transform picture to text, supporting Chinese
一个将图片转换成文字图的脚本,支持中文
刚学Python不久,代码不是特别简洁,因为要计算出灰度范围,导致循环了两次
为了支持中文,必须要使用中文字体
代码基本每一行都注释了 ![效果图](http://git.oschina.net/uploads/images/2016/0810/125741_ddd99bd4_346253.jpeg "效果图") # Dependencies 环境依赖 Python 2.7
PIL # How to use 如何使用 copy a font file to your directory and edit line 27:
拷贝一个字体文件到目录,然后修改代码27行中的字体名称: ```python ft = ImageFont.truetype("msyhbd.ttf",fontSize) ``` edit last several lines of codes:
编辑最后几行代码: ```python textList = ['撒','啊','呵','王','一'] pic2Text('test.jpg',textList) ``` sort characters by Density
按照字母笔画密集程度排列 # About 关于作者 不灭的小灯灯
Love programming,love designing
Mail:winterfeel@qq.com
Blog:www.winterfeel.com