cocos_screenshot_preview_diff
Compare PNG screenshots to detect visual changes and verify UI actions in Cocos Creator. Analyze pixel differences between before and after images to confirm whether interactions produce visible effects.
Instructions
Compare two PNG files on disk and report the change.
Lets an AI confirm whether an action actually DID something —
e.g. take a screenshot, click, take another, diff: if
diff_ratio is ~0 the click had no visible effect.
threshold is a per-channel absolute delta; pixels below are
considered identical (8 rejects typical PNG compression noise).
Returns {width, height, total_pixels, different_pixels,
diff_ratio} where diff_ratio is in [0, 1].
This tool is pure Pillow — it does NOT need playwright / chromium installed. Both inputs must be file paths; save via cocos_screenshot_preview first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| before_png_path | Yes | ||
| after_png_path | Yes | ||
| threshold | No |