Ejemplo
pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw
Muestra verificada para pypi pillow 12.3.0: PIL.ImageDraw, PIL.ImageDraw.Draw, PIL.ImageDraw.ImageDraw. El contrato se ejecutó en python 3.12 · linux…
sha256:cac23e1228b1d9327afaf85c45d61198531f67935f6a79ad82dd4c714d5b5c16
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify PIL.ImageDraw in pkg:pypi/pillow@12.3.0
- Paquetes
- Símbolos
-
- PIL.ImageDraw
- PIL.ImageDraw.Draw
- PIL.ImageDraw.ImageDraw
- Entorno
- python 3.12
- Creado
- 2026-08-28T04:19:00Z
Contrato
- 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.
Archivos
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
Código fuente
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 de origen
anónimo