示例
pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw
已验证示例 — pypi pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw. contract 在 python 3.12 · linux alpine/x64 · docker 上运行并通过.
sha256:cac23e1228b1d9327afaf85c45d61198531f67935f6a79ad82dd4c714d5b5c16
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-28 |
案例
HOW- 目标
- verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0
- 符号
-
- PIL.ImageDraw
- PIL.ImageDraw.Draw
- PIL.ImageDraw.ImageDraw
- 环境
- python 3.12
- 创建时间
- 2026-08-28T04:19:00Z
契约
- ImageDraw.Draw attaches to an Image canvas and returns an ImageDraw instance for in-place rendering.
- ImageDraw.Draw.point draws individual pixels at specified coordinates with given fill color.
- ImageDraw.Draw.line draws lines between coordinate sequences with fill color and width.
- ImageDraw.Draw.rectangle renders filled and outlined rectangles with bounding box coordinates.
- ImageDraw.Draw.ellipse renders filled and outlined ellipses within bounding boxes.
- ImageDraw.Draw.polygon renders filled and outlined polygons across multiple vertices.
- ImageDraw.Draw.rounded_rectangle renders rectangles with specified corner radii.
- ImageDraw.Draw.text renders string glyphs onto the image canvas.
- ImageDraw.Draw.regular_polygon renders n-sided regular polygons inside a bounding circle.
- ImageDraw.Draw raises an error when image argument is None.
文件
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
源代码
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/pillow@12.3.0
Demonstrate these symbols/APIs:
- PIL.ImageDraw
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:0c44583f6889d6fe7a58a25ca0317eec4d45f540bebc1499f11b51658e7cf243","contract":["ImageDraw.Draw attaches to an Image canvas and returns an ImageDraw instance for in-place rendering.","ImageDraw.Draw.point draws individual pixels at specified coordinates with given fill color.","ImageDraw.Draw.line draws lines between coordinate sequences with fill color and width.","ImageDraw.Draw.rectangle renders filled and outlined rectangles with bounding box coordinates.","ImageDraw.Draw.ellipse renders filled and outlined ellipses within bounding boxes.","ImageDraw.Draw.polygon renders filled and outlined polygons across multiple vertices.","ImageDraw.Draw.rounded_rectangle renders rectangles with specified corner radii.","ImageDraw.Draw.text renders string glyphs onto the image canvas.","ImageDraw.Draw.regular_polygon renders n-sided regular polygons inside a bounding circle.","ImageDraw.Draw raises an error when image argument is None."],"goal":"verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0","kind":"HOW","packages":["pkg:pypi/pillow@12.3.0"],"schemaVersion":1,"symbols":["PIL.ImageDraw","PIL.ImageDraw.Draw","PIL.ImageDraw.ImageDraw"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pillow@12.3.0"],"schemaVersion":1,"subject":"pkg:pypi/pillow@12.3.0","symbols":["PIL.ImageDraw","PIL.ImageDraw.Draw","PIL.ImageDraw.ImageDraw"],"verifierAdapter":"python@1"}
pillow==12.3.0
{
"schemaVersion": 1,
"goal": "verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0",
"kind": "HOW",
"packages": [
"pkg:pypi/pillow@12.3.0"
],
"symbols": [
"PIL.ImageDraw"
]
}
import sys
import PIL
from PIL import Image, ImageDraw
# Verify Pillow version and ImageDraw module
assert PIL.__version__ == "12.3.0"
assert hasattr(ImageDraw, "Draw")
assert hasattr(ImageDraw, "ImageDraw")
# 1. ImageDraw.Draw attaches to an image and mutates it
img = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
assert isinstance(draw, ImageDraw.ImageDraw)
# 2. Point drawing
draw.point((0, 0), fill=(255, 0, 0))
draw.point([(1, 1), (2, 2)], fill=(0, 255, 0))
assert img.getpixel((0, 0)) == (255, 0, 0)
assert img.getpixel((1, 1)) == (0, 255, 0)
assert img.getpixel((2, 2)) == (0, 255, 0)
# 3. Line drawing with width
img_line = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_line = ImageDraw.Draw(img_line)
draw_line.line([(0, 5), (19, 5)], fill=(0, 0, 255), width=1)
assert img_line.getpixel((0, 5)) == (0, 0, 255)
assert img_line.getpixel((10, 5)) == (0, 0, 255)
assert img_line.getpixel((19, 5)) == (0, 0, 255)
assert img_line.getpixel((10, 4)) == (0, 0, 0)
# 4. Rectangle drawing with fill and outline
img_rect = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_rect = ImageDraw.Draw(img_rect)
draw_rect.rectangle([(2, 2), (8, 8)], fill=(100, 100, 100), outline=(255, 255, 255), width=1)
# Outline border
assert img_rect.getpixel((2, 2)) == (255, 255, 255)
assert img_rect.getpixel((8, 8)) == (255, 255, 255)
# Filled interior
assert img_rect.getpixel((5, 5)) == (100, 100, 100)
# Outside
assert img_rect.getpixel((0, 0)) == (0, 0, 0)
# 5. Ellipse drawing with fill and outline
img_ellipse = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_ellipse = ImageDraw.Draw(img_ellipse)
draw_ellipse.ellipse([(2, 2), (8, 8)], fill=(200, 50, 50), outline=(255, 255, 0), width=1)
assert img_ellipse.getpixel((5, 5)) == (200, 50, 50)
assert img_ellipse.getpixel((0, 0)) == (0, 0, 0)
# 6. Polygon drawing
img_poly = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_poly = ImageDraw.Draw(img_poly)
draw_poly.polygon([(5, 2), (9, 8), (1, 8)], fill=(50, 200, 50), outline=(0, 255, 255))
assert img_poly.getpixel((5, 5)) == (50, 200, 50)
assert img_poly.getpixel((0, 0)) == (0, 0, 0)
# 7. Rounded rectangle drawing
img_round = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_round = ImageDraw.Draw(img_round)
draw_round.rounded_rectangle([(2, 2), (18, 18)], radius=3, fill=(120, 120, 120))
assert img_round.getpixel((10, 10)) == (120, 120, 120)
# Corner at (2,2) should be untouched due to radius
assert img_round.getpixel((2, 2)) == (0, 0, 0)
# 8. Text drawing
img_text = Image.new("RGB", (50, 20), color=(0, 0, 0))
draw_text = ImageDraw.Draw(img_text)
draw_text.text((2, 2), "PIL", fill=(255, 255, 255))
# Verify text was rendered onto the canvas
rendered_pixels = [img_text.getpixel((x, y)) for x in range(50) for y in range(20)]
assert any(p != (0, 0, 0) for p in rendered_pixels)
# 9. Regular polygon drawing
img_reg_poly = Image.new("RGB", (20, 20), color=(0, 0, 0))
draw_reg_poly = ImageDraw.Draw(img_reg_poly)
draw_reg_poly.regular_polygon(bounding_circle=((10, 10), 8), n_sides=6, fill=(150, 150, 0))
assert img_reg_poly.getpixel((10, 10)) == (150, 150, 0)
# 10. Error cases
try:
ImageDraw.Draw(None)
assert False, "Expected ValueError/TypeError when image is None"
except (ValueError, TypeError, AttributeError):
pass
print("PIL.ImageDraw contract passed")
原始种子者
匿名