==[[Python Imaging Library Modules]]==
[[Python Imaging Library]] | [[Python]] |
=====例=====
>>> import Image
>>> im = Image.new('RGB[[R]]GB', (100,100), (255,0,0))
>>> im.show()
[[File:1032_pil_img01.jpg]]
>>> import Image, ImageDraw
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.arc((10,10,80,80), 0, 270, fill=64)
*outline はアウトライン色、fill は塗りつぶす色を指定
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.chord((10,10,80,80), 0, 270, outline=(0,255,0), fill=(255,0,0))
*outline はアウトライン色、fill は塗りつぶす色を指定
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.ellipse((10,10,80,40),outline=(0,255,0), fill=(255,0,0))
*ver 1.1.5 から、 width オプションでピクセル単位で、線幅を指定できる。
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.line(((0,0),(50,50),(80,20)), fill='rgb(255,0,0)')
>>> import Image, ImageDraw
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.pieslice((10,10,80,80), 0, 270, fill=64)
*2 タプル [(x,y),...] または値のリスト、[x,y, ...] で位置を指定。
>>> import Image, ImageDraw
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> points = [(x, 100.0-(x / 4.0) **2) for x in range(100)]
>>> import Image, ImageDraw
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> points = [(20,40), (25,60), (40,80), (60,75), (80,95), (85,20), (50,40)]
>>> import Image, ImageDraw
>>> im = Image.new('RGB[[R]]GB', (100,100), 'rgb(128,128,128)')
>>> draw = ImageDraw.Draw(im)
>>> draw.rectangle(((20,20),(80,80)), fill=64, outline='rgb(0,255,0)')
import Image, ImageDraw, ImageFont
im = Image.new('RGB[[R]]GB', (300,300), 'rgb(255,255,255)')
draw = ImageDraw.Draw(im)
font = ImageFont.truetype('C:\WINDOWS\Fonts\MSMINCHO.TTC', 24, encoding="utf-8")
import Image, ImageDraw, ImageFont
im = Image.new('RGB[[R]]GB', (300,100), 'rgb(255,255,255)')
draw = ImageDraw.Draw(im)
font = ImageFont.truetype('C:\WINDOWS\Fonts\MSMINCHO.TTC', 24, encoding="utf-8")