CodeSampleX

サンプル

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. python 3.12 · linux alpine/x64 · docker で contract を実行し、成功しました.

sha256:cac23e1228b1d9327afaf85c45d61198531f67935f6a79ad82dd4c714d5b5c16

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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

コントラクト

  1. ImageDraw.Draw attaches to an Image canvas and returns an ImageDraw instance for in-place rendering.
  2. ImageDraw.Draw.point draws individual pixels at specified coordinates with given fill color.
  3. ImageDraw.Draw.line draws lines between coordinate sequences with fill color and width.
  4. ImageDraw.Draw.rectangle renders filled and outlined rectangles with bounding box coordinates.
  5. ImageDraw.Draw.ellipse renders filled and outlined ellipses within bounding boxes.
  6. ImageDraw.Draw.polygon renders filled and outlined polygons across multiple vertices.
  7. ImageDraw.Draw.rounded_rectangle renders rectangles with specified corner radii.
  8. ImageDraw.Draw.text renders string glyphs onto the image canvas.
  9. ImageDraw.Draw.regular_polygon renders n-sided regular polygons inside a bounding circle.
  10. ImageDraw.Draw raises an error when image argument is None.

ファイル

  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
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.
csx.json
{"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"}
requirements.txt
pillow==12.3.0
spec.json
{
  "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"
  ]
}
test/contract.py
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")

オリジンシーダー

匿名