From 44dc26d13e30f55f27130e4c59799aa97281fbf0 Mon Sep 17 00:00:00 2001 From: lededev Date: Sun, 10 Apr 2022 10:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=81=E9=9D=A2=E8=A3=81?= =?UTF-8?q?=E5=89=AA=E5=AE=BD=E9=AB=98=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ImageProcessing/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ImageProcessing/__init__.py b/ImageProcessing/__init__.py index f0b7fe5..539623e 100644 --- a/ImageProcessing/__init__.py +++ b/ImageProcessing/__init__.py @@ -7,6 +7,8 @@ from PIL import Image import shutil from ADC_function import file_not_exist_or_empty +g_width_half_ratio = 2.12 + def face_crop_width(filename, width, height): # 新宽度是高度的2/3 cropWidthHalf = int(height/3) @@ -22,15 +24,15 @@ def face_crop_width(filename, width, height): # 越界处理 if cropLeft < 0: cropLeft = 0 - cropRight = cropWidthHalf*2 + cropRight = cropWidthHalf*g_width_half_ratio elif cropRight > width: - cropLeft = width-cropWidthHalf*2 + cropLeft = width-cropWidthHalf*g_width_half_ratio cropRight = width return (cropLeft, 0, cropRight, height) except: print('[-]Not found face! ' + filename) # 默认靠右切 - return (width-cropWidthHalf*2, 0, width, height) + return (width-cropWidthHalf * g_width_half_ratio, 0, width, height) def face_crop_height(filename, width, height): @@ -69,7 +71,7 @@ def cutImage(imagecut, path, fanart_path, poster_path, skip_facerec=False): if width/height > 2/3: # 如果宽度大于2 if skip_facerec: # 有码封面默认靠右切 - img2 = img.crop((width - int(height/3) * 2, 0, width, height)) + img2 = img.crop((width - int(height/3) * g_width_half_ratio, 0, width, height)) else: # 以人像为中心切取 img2 = img.crop(face_crop_width(fullpath_fanart, width, height))