from PIL import Image, ImageDraw im = Image.new('RGB', (600, 400), (255, 255, 255)) draw = ImageDraw.Draw(im) draw.line((200, 200, 300, 300), fill=(0, 0, 255), width=20) im.save('kep.jpg', quality=95)
from PIL import Image, ImageDraw im = Image.new('RGB', (600, 400), (255, 255, 255)) draw = ImageDraw.Draw(im) draw.rectangle((200, 200, 300, 300), fill=(0, 192, 192), outline=(128, 128, 128)) im.show()
Kör rajzolása:
from PIL import Image, ImageDraw im = Image.new('RGB', (600, 400), (255, 255, 255)) draw = ImageDraw.Draw(im) # ellipse(x0, y0, x1, y1) # x0, y0 a doboz bal felső sarka # x1, y1 a doboz jobb alsó sarka draw.ellipse((200, 200, 300, 300), fill=(255, 255, 0), outline=(0, 0, 255)) im.show()
from PIL import Image, ImageDraw im = Image.new('RGB', (600, 400), (255, 255, 255)) draw = ImageDraw.Draw(im) draw.rectangle((200, 200, 300, 300), fill=(0, 192, 192), outline=(128, 128, 128)) im.save('kep.jpg', quality=95)
Készítsünk egy képet:
from PIL import Image, ImageDraw im = Image.new('RGB', (600, 400), (255, 255, 255)) draw = ImageDraw.Draw(im) draw.rectangle((200, 200, 300, 300), fill=(0, 192, 192), outline=(128, 128, 128)) im.save('kep01.png')
Most nyissuk meg a képet, rajzoljunk rá, majd más néven mentsük el.
from PIL import Image, ImageDraw im = Image.open("kep01.png") draw = ImageDraw.Draw(im) draw.ellipse((200, 200, 300, 300), fill=(255, 255, 0), outline=(0, 0, 255)) im.save('kep02.png')
from PIL import Image, ImageDraw box = (100, 100, 200, 200) im = Image.new('L', (600, 400), 12) draw = ImageDraw.Draw(im) draw.ellipse(box, 255) im.show()
from PIL import Image, ImageDraw im = Image.new('RGB', (300, 300), (255, 255, 255)) draw = ImageDraw.Draw(im) west_north = (100, 100) east_south = (200, 200) outline_color = (128, 128, 128) draw.rectangle([west_north, east_south], outline=outline_color) im.show()