A selfie can be front-facing, sharp, and still carry a red or amber flash bounce in the pupils. This script looks at that bounce, and only that bounce, before you upload a photo to a Malfoid portrait preset.
I run the studio at Malfoid AI. It makes a still Female Malfoy / Fem Draco portrait, from a photo of an adult or without a photo, for $4.99 / 2 credits. The resolution setting is 1K. There is no video and no prompt box. Credit packs, if you want them, are one-time purchases after sign-in: $13.99 for 30, $35.99 for 100, $59.99 for 200. Prices are from the pricing page, re-checked 1 December 2026, 18:26:08–18:26:42 Asia/Shanghai. There is no December sale on the live pages. The photos in this article are synthetic construction drawings — shapes only — not studio outputs and not anyone's picture.
This is not a blink / eye-aspect-ratio check, not a sunglasses occlusion check, not a gaze / iris-position check, not a screen-glare check, and not a fringe / bangs check. Those questions are about whether the eye is visible or where the iris sits. This one only asks whether the pupil disk has a red or amber reflection. The official photo-requirements guide already asks for a clear, front-facing photo of one adult, and it lists "harsh flash" among the lighting problems. A red pupil is a common leftover of that flash.
Red vs amber, in one disk
The detector closes the white sclera ring so a painted pupil does not split one eye into two crescents, then it picks the pair whose gap is a plausible inter-ocular distance (about 108 px on the 768-wide construction drawing). Each eye is scored in a tight 7-px disk around that centre:
RED_KEEP = 0.08
RED_FAIL = 0.28
AMBER_KEEP = 0.08
AMBER_FAIL = 0.28
# Red-eye: high red, low green, low blue.
red_mask = (r >= 150) & (b <= 80) & (g <= 70)
# Amber bounce: high red, mid green, low blue. Exclusive of red.
amber_mask = (r >= 150) & (b <= 80) & (g >= 90) & (g <= r - 20)
If the amber fraction on either eye is at least 0.28, the state is amber. If both eyes are at or above the red-fail line, the state is red. If only one eye crosses that line, the state is one_eye. Below the keep lines, the state is clear. The script does not retouch the photo.
The bench
Eight sitters × four pupil states (clear / red / one_eye / amber) × PNG + JPEG q95 = 64 files, 64/64. Median analyse 15.329704503528774 ms. Thresholds stay at RED_KEEP=0.08, RED_FAIL=0.28, and the same pair for amber. Seed 1, PNG, both pupils at (330.0, 389.0) and (438.0, 389.0), radius 7.0:
- clear: red 0.0 / amber 0.0, red ratio 0.3200488997555012,
clear - red: left and right red fraction 0.6510067114093959, red ratio 0.61899195810735,
red - one_eye: left red 0.6510067114093959, right red 0.0,
one_eye - amber: left and right amber fraction 0.6510067114093959, red 0.0,
amber
The script is redeye_check.py, with make_redeye_fixtures.py, bench_redeye.py, and test_redeye_check.py. It uses Pillow, NumPy, and OpenCV. If the pupils are clear, you can upload the photo. If one or both pupils are red or amber, retake the selfie without a direct flash — this checker will not paint the pupils back to dark for you.
Top comments (0)