commit fb6c745188c6b09bd0ffa28852a5a07e09ed9bcc Author: Cx330 <1487537121@qq.com> Date: Sat Mar 8 15:33:35 2025 +0800 finish diff --git a/homework_photo.png b/homework_photo.png new file mode 100644 index 0000000..90b15ef Binary files /dev/null and b/homework_photo.png differ diff --git a/photo.py b/photo.py new file mode 100644 index 0000000..4089c11 --- /dev/null +++ b/photo.py @@ -0,0 +1,22 @@ +from PIL import Image + +# 读取 128x128 的图片 +image_path = "homework_photo.png" +image = Image.open(image_path) + +# 使用三种插值方法放大到 512x512 +image_nearest = image.resize((512, 512), Image.NEAREST) # 最近邻插值 +image_linear = image.resize((512, 512), Image.BILINEAR) # 双线性插值 +image_cubic = image.resize((512, 512), Image.BICUBIC) # 立方插值 + +# 保存为指定文件名 +image.save("photo/原图.png") +image_nearest.save("photo/最近邻插值.png") +image_linear.save("photo/双线性插值.png") +image_cubic.save("photo/立方插值.png") + +# 打开保存的图片 +Image.open("photo/原图.png").show() +Image.open("photo/最近邻插值.png").show() +Image.open("photo/双线性插值.png").show() +Image.open("photo/立方插值.png").show() diff --git a/photo/README.md b/photo/README.md new file mode 100644 index 0000000..41764d0 --- /dev/null +++ b/photo/README.md @@ -0,0 +1 @@ +这是一个空文件!!! \ No newline at end of file