FEAT: Add ImageOverlayConverter for compositing images with overlays#1764
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Adds a new ImageOverlayConverter to the prompt-converter layer, enabling image-to-image compositing by placing an overlay image (prompt input) onto a configured base image with optional resizing and opacity control. This extends PyRIT’s image augmentation capabilities for scenario/dataset variation workflows (Issue #414).
Changes:
- Added
ImageOverlayConverterimplementation (base image + position + optional resize + opacity). - Exported the converter via
pyrit.prompt_converter. - Added unit tests and a documentation example (plus a sample overlay asset).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pyrit/prompt_converter/image_overlay_converter.py |
Implements the new overlay compositing converter and identifier wiring. |
pyrit/prompt_converter/__init__.py |
Exports ImageOverlayConverter from the package surface. |
tests/unit/prompt_converter/test_image_overlay_converter.py |
Adds unit coverage for init validation, compositing behavior, and convert_async. |
doc/code/converters/3_image_converters.py |
Adds a usage example section for ImageOverlayConverter. |
doc/code/converters/226md.png |
Adds a sample overlay image used by the documentation example. |
…nsion - Stop force-flattening composited result to RGB; keep RGBA so PNG/WEBP outputs preserve transparency. - For JPEG output, composite onto a white background to handle transparent overlays predictably. - Normalize jpg/jpeg file extension to 'jpg' for the output serializer to match other image converters. - Warn when the overlay (after resize) falls entirely outside the base image. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Adds a new
ImageOverlayConverterthat composites a prompt image (overlay) onto a configured base image at a specified position. This is useful for creating many variations of a scenario by layering different images on top of a base image (e.g., placing a CAPTCHA image over a photo).The converter supports:
position(x, y) for overlay placementoverlay_sizeto resize the overlay before compositingopacity(0.0–1.0) for the overlayFiles changed:
Issue: #414
Tests and Documentation
convert_asyncmethod.ImageOverlayConvertersection to the existing 3_image_converters.py Jupytext notebook demonstrating usage with configurable position, size, and opacity.