Personal tools
You are here: Home Pythonレシピブック その他 PILの操作
Views
Actions
  • State: Published

PythonからPython Imaging Libraryを操作(Resize)する。 ローカルファイルシステム(LFS)上のJPG画像をリサイズしてサムネイルをLFSに生成する。

# python:

 >>> import Image
 >>> origin = Image.open('origin.jpg')

 >>> size = (128, 96)
 >>> pil128x96 = origin.resize(size)
 >>> pil128x96.save('pil128x96.jpg')

 >>> size = (64, 48)
 >>> pil64x48 = origin.resize(size)
 >>> pil64x48.save('pil64x48.jpg')