I had a similar problem, my lines had rough edges where the directions changed. I figured out how lines are drawn in iOS and came up with this code. It overlays the rounded ends of the lines at the ends of the lines and really cleans things up. Not exactly anti-aliasing, but I'm completely new to PIL, and it was hard for me to find an answer that I thought I would share. Needs some tweaking, and probably a better way, but does what I need :)
from PIL import Image import ImageDraw class Point: def __init__(self, x, y): self.x = x self.y = y class DrawLines: def draw(self, points, color, imageName): img = Image.new("RGBA", [1440,1080], (255,255,255,0)) draw = ImageDraw.Draw(img) linePoints = [] for point in points: draw.ellipse((point.x-7, point.y-7, point.x+7, point.y+7), fill=color) linePoints.append(point.x) linePoints.append(point.y) draw.line(linePoints, fill=color, width=14) img.save(imageName) p1 = Point(100,200) p2 = Point(190,250) points = [p1,p2] red = (255,0,0) drawLines = DrawLines() drawLines.draw(points, red, "C:\\test.png")
Dave_750
source share