当前位置:   article > 正文

pillow读取&裁剪&写入图片_pillow随机裁剪

pillow随机裁剪

1. 导包

pillow就是PIL模块,安装方法pip install pillow,可以加入镜像源,比如:-i https://pypi.tuna.tsinghua.edu.cn/simple

from PIL import Image
import matplotlib.pyplot as plt
  • 1
  • 2

2. 设置读取和写入路径

pillow不区分中英文路径,都可以正确读入,功能强大,这一点比opencv更出色

PIL_in_path = "fruit1/脆桃/脆桃-19453282-321255571.png"
PIL_out_path = "fruit3/脆桃/脆桃-19453282-321255571.png"
  • 1
  • 2

3. 正确读取

img = Image.open(PIL_in_path)
print(img)  # <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=220x220 at 0x2377
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/804174
推荐阅读
相关标签
  

闽ICP备14008679号