新增选项:1.避免模式3跳过人脸识别 2.避免对有码封面进行人脸识别

This commit is contained in:
lededev
2022-04-10 07:14:55 +08:00
parent e951429ec0
commit 09c81d7f59
4 changed files with 27 additions and 19 deletions

View File

@@ -55,18 +55,24 @@ def face_crop_height(filename, width, height):
return (0, 0, width, cropHeight)
def cutImage(imagecut, path, fanart_path, poster_path):
def cutImage(imagecut, path, fanart_path, poster_path, skip_facerec=False):
fullpath_fanart = os.path.join(path, fanart_path)
fullpath_poster = os.path.join(path, poster_path)
if config.getInstance().download_only_missing_images() and not file_not_exist_or_empty(fullpath_poster):
if config.getInstance().face_aways_imagecut():
imagecut = 1
elif config.getInstance().download_only_missing_images() and not file_not_exist_or_empty(fullpath_poster):
return
if imagecut == 1: # 剪裁大封面
try:
img = Image.open(fullpath_fanart)
width, height = img.size
if width/height > 2/3: # 如果宽度大于2
# 以人像为中心切取
img2 = img.crop(face_crop_width(fullpath_fanart, width, height))
if skip_facerec:
# 有码封面默认靠右切
img2 = img.crop((width - int(height/3) * 2, 0, width, height))
else:
# 以人像为中心切取
img2 = img.crop(face_crop_width(fullpath_fanart, width, height))
elif width/height < 2/3: # 如果高度大于3
# 从底部向上切割
img2 = img.crop(face_crop_height(fullpath_fanart, width, height))