Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 文字转base64 #58

Open
dounai1306 opened this issue Sep 4, 2018 · 0 comments
Open

python 文字转base64 #58

dounai1306 opened this issue Sep 4, 2018 · 0 comments

Comments

@dounai1306
Copy link
Owner

dounai1306 commented Sep 4, 2018

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFont, ImageFilter
import base64
#
image = Image.new('RGBA', (480, 320), (255, 255, 255, 200))
# 创建Font对象:
font = ImageFont.truetype('msyh.ttf', 18)
# 创建Draw对象:
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, 800, 800), fill=(255, 255, 255, 255))
# 输出文字:
draw.text((0, 5), 'dounai', font=font, fill=(0, 0, 0, 255))
image.rotate(35)
image.save('dark.png', 'PNG')

f = open('dark.png', 'rb')
print base64.b64encode(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant