{"id":20902,"library":"aggdraw","title":"aggdraw","description":"High quality drawing interface for PIL/Pillow using the Anti-Grain Geometry library. Version 1.4.1, updated irregularly.","status":"active","version":"1.4.1","language":"python","source_language":"en","source_url":"https://github.com/pytroll/aggdraw","tags":["drawing","PIL","Pillow","anti-grain","imaging","graphics"],"install":[{"cmd":"pip install aggdraw","lang":"bash","label":"default"}],"dependencies":[{"reason":"aggdraw requires Pillow (PIL fork) to provide image objects.","package":"Pillow","optional":false}],"imports":[{"note":"The module is named 'aggdraw', but the main class is 'Draw'.","wrong":"from aggdraw import aggdraw","symbol":"Draw","correct":"from aggdraw import Draw"},{"note":null,"wrong":null,"symbol":"Pen","correct":"from aggdraw import Pen"},{"note":null,"wrong":null,"symbol":"Brush","correct":"from aggdraw import Brush"}],"quickstart":{"code":"from PIL import Image\nfrom aggdraw import Draw, Pen, Brush\n\nimg = Image.new('RGBA', (200, 200), 'white')\ndraw = Draw(img)\npen = Pen('black', 3)\nbrush = Brush('red')\ndraw.ellipse((50, 50, 150, 150), pen, brush)\ndraw.flush()\nimg.show()","lang":"python","description":"Creates a 200x200 white image, draws a red ellipse with a black outline, and displays it."},"warnings":[{"fix":"Upgrade Python to 3.11+ or pin to aggdraw==1.3.2 if on older Python.","message":"aggdraw >= 1.4.0 requires Python 3.11+. Older versions (e.g., 1.3.2) support Python 3.10 and below.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"Always call draw.flush() after drawing operations.","message":"The 'Draw' object does not work directly on PIL Images; you must call 'draw.flush()' to apply changes to the underlying image. Forgetting flush results in a blank image.","severity":"breaking","affected_versions":"all"},{"fix":"Ensure all coordinates are integers (e.g., (int(x), int(y))).","message":"aggdraw uses integer coordinates; passing floats may truncate silently.","severity":"gotcha","affected_versions":"all"},{"fix":"Use PIL.ImageFont.truetype() and pass the font object to Draw.text().","message":"The 'Font' class is deprecated in favor of using PIL's ImageFont directly. Font handling may change in future versions.","severity":"deprecated","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from aggdraw import Draw","cause":"Incorrect import path. The class is in the top-level module.","error":"ImportError: cannot import name 'Draw' from 'aggdraw'"},{"fix":"Install with pip: pip install aggdraw. Ensure you have build tools (e.g., 'python3-dev' on Linux).","cause":"aggdraw is not installed or installation failed (requires compiler for C extension).","error":"ModuleNotFoundError: No module named 'aggdraw'"},{"fix":"Use aggdraw version >=1.2.0. For older versions, use PIL's ImageDraw.Draw.text instead.","cause":"The 'text' method was added in a later version or requires specific parameters.","error":"aggdraw.Draw: AttributeError: 'Draw' object has no attribute 'text'"},{"fix":"Convert numpy array to PIL Image using Image.fromarray().","cause":"Confusion with numpy arrays, but aggdraw expects PIL Images.","error":"RuntimeError: The truth value of an array with more than one element is ambiguous."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}