mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
Update img_utils.py
This commit is contained in:
parent
0dfca7e23d
commit
edbbcec1be
@ -2,6 +2,7 @@ import os
|
||||
from configs.path_config import IMAGE_PATH, TXT_PATH, TTF_PATH
|
||||
from PIL import Image, ImageFile, ImageDraw, ImageFont
|
||||
import cv2
|
||||
from typing import Tuple
|
||||
import imagehash
|
||||
import base64
|
||||
from io import BytesIO
|
||||
@ -223,6 +224,18 @@ class CreateImg:
|
||||
self.current_w += self.img_w
|
||||
return self.markImg
|
||||
|
||||
def crop(self, box: Tuple[int, int, int, int]):
|
||||
"""
|
||||
说明:
|
||||
裁剪图片
|
||||
参数:
|
||||
:param box: 左上角坐标,右下角坐标 (left, upper, right, lower)
|
||||
"""
|
||||
self.markImg = self.markImg.crop(box)
|
||||
self.w, self.h = self.markImg.size
|
||||
self.size = self.w, self.h
|
||||
self.draw = ImageDraw.Draw(self.markImg)
|
||||
|
||||
# 获取文字大小
|
||||
def getsize(self, msg):
|
||||
return self.ttfont.getsize(msg)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user