matplotlib & pandas

This commit is contained in:
estomm
2020-09-26 22:03:11 +08:00
parent 73cc328c81
commit d31be4f219
599 changed files with 99925 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
# 图像缩略图
您可以使用matplotlib从现有图像生成缩略图。matplotlib本身支持输入端的PNG文件如果安装了PIL则透明地支持其他图像类型。
```python
# build thumbnails of all images in a directory
import sys
import os
import glob
import matplotlib.image as image
if len(sys.argv) != 2:
print('Usage: python %s IMAGEDIR' % __file__)
raise SystemExit
indir = sys.argv[1]
if not os.path.isdir(indir):
print('Could not find input directory "%s"' % indir)
raise SystemExit
outdir = 'thumbs'
if not os.path.exists(outdir):
os.makedirs(outdir)
for fname in glob.glob(os.path.join(indir, '*.png')):
basedir, basename = os.path.split(fname)
outfile = os.path.join(outdir, basename)
fig = image.thumbnail(fname, outfile, scale=0.15)
print('saved thumbnail of %s to %s' % (fname, outfile))
```
## 下载这个示例
- [下载python源码: image_thumbnail_sgskip.py](https://matplotlib.org/_downloads/image_thumbnail_sgskip.py)
- [下载Jupyter notebook: image_thumbnail_sgskip.ipynb](https://matplotlib.org/_downloads/image_thumbnail_sgskip.ipynb)