blob: cb5387adcd04f49c45399785bc69c023ef17a073 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import os
import base64
from pathlib import Path
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
|