mirror of
https://github.com/CHERWING/CHERWIN_SCRIPTS.git
synced 2024-11-22 09:04:11 +08:00
Update CHERWIN_TOOLS.py
This commit is contained in:
parent
5b5733a684
commit
1e39544e6c
@ -6,7 +6,7 @@ import sys
|
|||||||
import requests
|
import requests
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
NOW_TOOLS_VERSION = '2024.04.08'
|
NOW_TOOLS_VERSION = '2024.05.04'
|
||||||
if os.path.isfile('DEV_ENV.py'):
|
if os.path.isfile('DEV_ENV.py'):
|
||||||
import DEV_ENV
|
import DEV_ENV
|
||||||
# 尝试导入包
|
# 尝试导入包
|
||||||
@ -362,39 +362,29 @@ def CAPCODE(captcha_slider, captcha_bg):
|
|||||||
else:
|
else:
|
||||||
print('ddddocr 模块无法导入,函数无法执行。')
|
print('ddddocr 模块无法导入,函数无法执行。')
|
||||||
return False
|
return False
|
||||||
#
|
|
||||||
# def OCR_API(target_b64str,bg_b64str):
|
def BASE64_TO_IMG(base64_string, output_path):
|
||||||
# import base64
|
import base64
|
||||||
# host = 'http://192.168.10.160'
|
import io
|
||||||
# jsonstr = json.dumps({'target_img': target_b64str, 'bg_img': bg_b64str})
|
Image = import_or_install('Pillow', 'PIL.Image')
|
||||||
# api_url = f"{host}/slide/match/b64/json"
|
|
||||||
# resp = requests.post(api_url, data=base64.b64encode(jsonstr.encode()).decode())
|
if Image:
|
||||||
# print(f"{api_url=}, {resp.text=}")
|
try:
|
||||||
# return resp.json().get('target_y',0)
|
# 解码base64字符串
|
||||||
#
|
image_data = base64.b64decode(base64_string)
|
||||||
#
|
# 将字节数据转换为字节流
|
||||||
# def BASE64_TO_IMG(base64_string, output_path):
|
image_buf = Image.open(io.BytesIO(image_data))
|
||||||
# import base64
|
# 转换为RGB模式
|
||||||
# import io
|
image_buf = image_buf.convert('RGB')
|
||||||
# Image = import_or_install('Pillow', 'PIL.Image')
|
# 保存图片到指定路径
|
||||||
#
|
image_buf.save(output_path, format='JPEG')
|
||||||
# if Image:
|
return True
|
||||||
# try:
|
except Exception as e:
|
||||||
# # 解码base64字符串
|
print(f'发生错误:{e}')
|
||||||
# image_data = base64.b64decode(base64_string)
|
return False
|
||||||
# # 将字节数据转换为字节流
|
else:
|
||||||
# image_buf = Image.open(io.BytesIO(image_data))
|
print('需要的模块[PIL]无法导入,函数无法执行。')
|
||||||
# # 转换为RGB模式
|
return False
|
||||||
# image_buf = image_buf.convert('RGB')
|
|
||||||
# # 保存图片到指定路径
|
|
||||||
# image_buf.save(output_path, format='JPEG')
|
|
||||||
# return True
|
|
||||||
# except Exception as e:
|
|
||||||
# print(f'发生错误:{e}')
|
|
||||||
# return False
|
|
||||||
# else:
|
|
||||||
# print('需要的模块[PIL]无法导入,函数无法执行。')
|
|
||||||
# return False
|
|
||||||
|
|
||||||
def send_wxpusher(UID, one_msg, APP_NAME, help=False):
|
def send_wxpusher(UID, one_msg, APP_NAME, help=False):
|
||||||
WXPUSHER = os.environ.get('WXPUSHER', False)
|
WXPUSHER = os.environ.get('WXPUSHER', False)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user