def generate_avatar(dir, filename):
"""
????????????dir/avatar_filename
:return: ?????????bool?
"""
pil_image = numpy.array(Image.open(os.path.join(dir, filename)));
image = None;
try:
image = cv2.cvtColor(numpy.array(pil_image), cv2.COLOR_RGB2BGR);
except:
image = numpy.array(pil_image);
avatar = crop_avatar(image);
if avatar is None:
return False;
else:
cv2.imwrite(os.path.join(dir, "avatar_" + filename), avatar);
return True;
评论列表
文章目录