Exemple
pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw
Échantillon vérifié pour pypi pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw. Le contrat s'est exécuté sur python 3.12 · linux…
sha256:cac23e1228b1d9327afaf85c45d61198531f67935f6a79ad82dd4c714d5b5c16
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0
- Paquets
- Symboles
-
- PIL.ImageDraw
- PIL.ImageDraw.Draw
- PIL.ImageDraw.ImageDraw
- Environnement
- python 3.12
- Créé
- 2026-08-28T04:19:00Z
Contrat
- 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.
Fichiers
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
Code source
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")
Seeder d'origine
anonyme