-
Notifications
You must be signed in to change notification settings - Fork 2
Creating a Generator
Sepehr0Day edited this page Jun 13, 2026
·
1 revision
Use VisualChallenge when the generator creates a visual asset.
from PIL import Image, ImageDraw
from CaptchaGenerator.core import ChallengeResult, VisualChallenge
class ExampleCaptcha(VisualChallenge):
def generate(
self,
*,
name_export: str,
path_export: str,
) -> ChallengeResult:
config = self._config(None)
image = Image.new("RGB", config.size, config.background_color)
draw = ImageDraw.Draw(image)
draw.text((40, 40), "Question", fill=config.foreground_color)
return self._save(
image,
path_export=path_export,
name_export=name_export,
answer="answer",
prompt="Enter the answer.",
metadata={},
config=config,
)Then:
- Add the module to
CaptchaGenerator/generators. - Export the class from
generators/__init__.pyand package__init__.py. - Add it to
SUPPORTED_CAPTCHAS. - Add focused tests.
- Add
simple.pyandinteractive.pyexamples. - Document answer and metadata contracts.
- Home
- Installation
- Quick-Start
- Configuration
- Core-API
- Generator-API-Reference
- Core-Utilities
- Supported-CAPTCHAs
- All-Examples
- Text-and-Media-CAPTCHAs
- Logic-CAPTCHAs
- Image-CAPTCHAs
- Selection-CAPTCHAs
- Puzzle-CAPTCHAs
- Visual-Reasoning-CAPTCHAs
- Tkinter-Examples
- Web-Integration
- Architecture
- Creating-a-Generator
- Security
- Publishing
- Migration-to-2.0
- FAQ