Skip to content

FEAT: Add ImageBlurConverter (Gaussian blur) - #4433

Merged
Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
khushi-git-7:feat/4398-image-blur-converter
Nov 24, 2026
Merged

Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
khushi-git-7:feat/4398-image-blur-converter

Conversation

@khushi-git-7

@khushi-git-7 Khushi (khushi-git-7) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds ImageBlurConverter, which applies a Gaussian blur to an image to check whether a target still reads, and image-based filtering still catches, text rendered into a blurred image. Closes #4398.

  • Subclasses BaseImageToImageConverter and uses ImageFilter.GaussianBlur(radius); radius (default 2.0) must be finite and greater than 0, otherwise ValueError. The size is preserved.
  • Images with transparency are blurred with premultiplied alpha (RGBa). A plain RGBA blur mixes the hidden color of fully transparent pixels into the visible edge (a transparent red area next to opaque blue gives a purple fringe), and there is a test for this.
  • Exported from pyrit.converter, with a section in 3_image_converters after ImageResizingConverter, and the converter table in 0_converters updated.
  • An RGB image with a transparent color key is converted to RGBA first, so it takes the premultiplied path too.

This and #4432 (for #4399) both add a row to the 0_converters table, so whichever lands second will need a rebase there. I'll take care of it.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

RGB PNGs with color-key transparency bypass alpha-aware blurring, allowing hidden colors to bleed into visible pixels and leaving alpha edges unblurred.

1 open issue
What changed in this PR

Adds ImageBlurConverter to PyRIT’s image converter stack for testing multimodal robustness to Gaussian blur, addressing #4398.

Changes:

  • Implements configurable blur with radius validation, size preservation, and premultiplied-alpha handling.
  • Exports the converter through the lazy-loading public API.
  • Adds unit tests, a usage example, and a converter-table entry.
File Description
tests/​unit/​converter/​test_image_blur_converter.py Tests validation, blur behavior, image modes, transparency, and input handling.
pyrit/​converter/​image_blur_converter.py Implements Gaussian blur and parameter identification.
pyrit/​converter/​__init__.py Adds the public lazy export and typing import.
doc/​code/​converters/​3_image_converters.py Adds a blur usage example.
doc/​code/​converters/​0_converters.ipynb Lists the converter’s supported input and output types.

Review effort: Balanced

Comment thread pyrit/converter/image_blur_converter.py Resolved
An RGB image with a transparent color key now becomes RGBA inside
_convert_to_rgb_or_rgba, so every image converter gets an alpha channel
its transform cannot silently drop, instead of each subclass promoting
it separately. ImageBlurConverter's local promotion is removed; its
color-key test now covers the shared path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into microsoft:main with commit c04b74e Nov 24, 2026
66 checks passed
@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Thanks for the review, for moving the colour-key handling into the base class, and for the merge, Roman Lutz (@romanlutz).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Add ImageBlurConverter (Gaussian blur)

3 participants