import cv2


def resize_image(input_path, output_path, new_width=200):
    # 读取原始图片
    img = cv2.imread(input_path, cv2.IMREAD_UNCHANGED)
    # 计算新的高度，保持纵横比
    height, width = img.shape[:2]
    width_percent = (new_width / float(width))
    new_height = int((float(height) * width_percent))
    
    # 调整图片大小
    # resized_img = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_LANCZOS4)
    resized_img = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_AREA)

    # 保存调整后的图片
    cv2.imwrite(output_path, resized_img)
    print(f"图片已保存为 {output_path}")



          
if __name__ == "__main__":
    resize_image("./input/image.png","temp2.png")
    