LoginSignup
3
4

More than 5 years have passed since last update.

Pythonで画像処理

Posted at

PILの導入

PIL(Python Imaging Library)を使います

PILについてはこちら
http://www.lifewithpython.com/2013/09/pil.html

ダウンロード

http://www.pythonware.com/products/pil/
公式サイトから自分のOSなどにあったものをダウンロードしてください

ダウンロードして、そのフォルダに移動した後に以下の手順でインストールします。

cd Imaging-1.1.7
sudo python setup.py install

画像をマスクする

mask.py
from PIL import Image, ImageOps
mask = Image.open("マスク画像のパス")
org = Image.open("元画像のパス")
sq = ImageOps.fit(sq, (400, 400), method = Image.LANCZOS)
sq.putalpha(mask.convert("L"))
sq.save("丸く切りぬいた画像の保存先のパス")

(おまけ)QRコードを読み書き

http://nixeneko.hatenablog.com/entry/2016/01/25/023703
http://qiita.com/kiyota-yoji/items/7fe134a64177ed708fdd

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4