diff options
author | Kyomotoi <[email protected]> | 2020-08-11 00:08:59 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2020-08-11 00:08:59 +0800 |
commit | 892ae018b1b9ab52f3ee4b751893d70bd81ea777 (patch) | |
tree | 70312fbfb92d9569b33d047179ed7ac374c6aaf4 /ATRI/modules/b64 | |
parent | 97bf675947264bbf1b39e595e8286751616f27c2 (diff) | |
download | ATRI-892ae018b1b9ab52f3ee4b751893d70bd81ea777.tar.gz ATRI-892ae018b1b9ab52f3ee4b751893d70bd81ea777.tar.bz2 ATRI-892ae018b1b9ab52f3ee4b751893d70bd81ea777.zip |
[Update]
Diffstat (limited to 'ATRI/modules/b64')
-rw-r--r-- | ATRI/modules/b64/__init__.py | 40 | ||||
-rw-r--r-- | ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc | bin | 0 -> 1022 bytes |
2 files changed, 40 insertions, 0 deletions
diff --git a/ATRI/modules/b64/__init__.py b/ATRI/modules/b64/__init__.py new file mode 100644 index 0000000..2c800a0 --- /dev/null +++ b/ATRI/modules/b64/__init__.py @@ -0,0 +1,40 @@ +import os +import time +import base64 +import requests +from pathlib import Path +from PIL import Image, ImageGrab + + +path_emoji = Path('.') / 'ATRI' / 'data' / 'emoji' +path_temp_img = Path('.') / 'ATRI' / 'data' / 'temp' / 'img' +path_img = Path('.') / 'ATRI' / 'data' / 'img' + + +def b64_str_emoji(file_name: str): + find_file = os.path.join(str(path_emoji) + '/' + file_name) + with open(find_file, 'rb') as f: + content = f.read() + b64_str = base64.b64encode(content).decode() + return b64_str + +# def b64_str_img_url(url: str): +# img_d = requests.get(url) +# name = 'temp.jpg' +# with open(str(path_temp_img) + '/' + name, 'wb') as f: +# f.write(img_d.content) +# find_img = os.path.join(str(path_temp_img) + '/' + name) +# with open(find_img, 'rb') as f: +# content = f.read() +# img = ImageGrab. +# b64_str = base64.b64encode(content).decode() +# time.sleep(1) +# os.remove(str(path_temp_img) + '/' + name) +# return b64_str + +def b64_str_img_path(file_name: str): + find_file = os.path.join(str(path_img) + '/' + file_name) + with open(find_file, 'rb') as f: + content = f.read() + b64_str = base64.b64encode(content).decode() + return b64_str
\ No newline at end of file diff --git a/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc b/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc Binary files differnew file mode 100644 index 0000000..5b3821c --- /dev/null +++ b/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc |