Tuesday, November 11, 2008

Python Imaging Libraryで円を描画する

Python Imaging Libraryで円を描画するには、以下のコードを実行します。

# coding=UTF-8
import Image
import ImageDraw
# 円を描画する
img1 = Image.new("RGB", (100,100), (0xff, 0xff, 0xff))
draw = ImageDraw.Draw(img1)
draw.ellipse((0,0,99,99), outline=(0x00, 0x00, 0x00), fill=(0xbb, 0xdd, 0xff))
del draw
img1.save("sample630a.jpg")

出力画像(sample630a.jpg)


関連項目
Python Imaging Libraryまとめ
Python Imaging Libraryを使用して画像を円形に切り取る

No comments: