Designing Semantic Chat Cropping
Designing Semantic Chat Cropping Systems
To specify a system that lets AI intelligently select and "drag-crop" chat bubble ranges (instead of raw pixel cropping), define these four pillars:
- Detection stack: Object Detection (bubble bounding boxes) + OCR (text content) + Contextual Anchor Logic (evidentiary keywords)
- Decision flow: Detect → Read → Anchor (start/end) → Compute crop region → Output
- Conditions: boundary contrast, keyword dictionary, aspect-ratio preservation
- Prohibitions: never bisect a bubble, never crop without context, never strip timestamps/profile marks
Use this skill to produce a full system spec (methods, step-by-step flow, conditions, prohibitions) in the same structure every time, adaptable to any chat platform or evidence domain (not just financial fraud — also harassment, contract disputes, etc.).
Progress:
- Step 1: Define the object taxonomy for the target chat UI
- Step 2: Specify the OCR/text-analysis layer
- Step 3: Define the anchor keyword dictionary for the domain
- Step 4: Write the 5-step decision flow (Detect → Read → Anchor → Compute → Crop)
- Step 5: Enumerate system conditions (contrast, keyword set, aspect ratio, output canvas)
- Step 6: Enumerate strict prohibitions (no bisecting, no floating context-free bubbles, no metadata stripping)
- Step 7: Validate spec against edge cases (oversized bubbles, ambiguous anchors, low-contrast themes)
Step 1: Object Taxonomy
List every UI element the detector must classify, at minimum:
- Left bubble (incoming), right bubble (outgoing)
- Attached image / sticker / voice message
- Profile icon, sender name
- Timestamp, read-receipt marker
- System messages (e.g., "user joined", date dividers)
Step 2: OCR / Text Layer
- Language-specific OCR engine (e.g., Thai, English, mixed)
- Output:
{bubble_id, bbox, text_string, sender_side, timestamp} - Confidence threshold below which a bubble is flagged for human review rather than auto-cropped
Step 3: Anchor Keyword Dictionary
Define domain-specific start/end anchor terms. Example (financial evidence):
- Start anchors: account number, price agreement, "how much total"
- End anchors: "transferred", slip/receipt image, "payment sent"
For other domains (harassment, threats, contract agreement), swap the dictionary — the architecture stays the same, only the keyword set changes.
Step 4: Decision Flow (5 steps)
- Object Detection — scan full long screenshot, produce bbox map for every bubble
(x_min, y_min, x_max, y_max) - Text Content Analysis — OCR every detected bubble into text strings
- Anchor Identification — run keyword decision tree to find
Start Anchorbubble andEnd Anchorbubble - Auto-Drag Simulation — compute crop region:
y_top = y_start_anchor - 10px(margin)y_bottom = y_end_anchor + 10px(margin)- Add ±1–2 bubble contextual buffer before/after the anchor range
- Precision Crop Output — cut the original long image along the computed vertical band; discard unrelated content outside the band
Step 5: System Conditions
- Boundary Contrast Condition: bubble border/background must have sufficient contrast for reliable bbox detection; flag low-contrast themes for manual fallback
- Evidence Keyword Condition: maintain an extensible, domain-configurable keyword dictionary; anchor detection must fail safely (ask for human confirmation) if no clear anchor found
- Aspect Ratio Constraint: cropped output resized onto standard canvas (e.g., 645×890px) preserving original text proportions — no single-axis stretch/distortion
Step 6: Strict Prohibitions
- No bisecting bubbles: never cut through the middle of a bubble inside the selected range; if a bubble overflows the canvas, resize the canvas or push the whole bubble to the next page
- No context-free floating bubbles: never output an isolated bubble (e.g., only "transferred") without the preceding conversational context or referenced attachment — context-less evidence is legally weak
- No metadata stripping: never remove timestamps, read-receipts, or profile icons during crop — required for Chain-of-Custody integrity
Example 1: Input: "Design a cropping system for LINE chat screenshots used as debt-collection evidence." Output: A spec following Steps 1–6 above, with:
- Object taxonomy tailored to LINE (green outgoing bubble, white incoming bubble, LINE Pay slip images)
- Keyword dictionary: "ยอดหนี้" (debt amount), "ทวงหนี้" (debt collection), "โอนแล้ว" (transferred), "สลิป" (slip)
- Decision flow identical structure, with start anchor = debt amount mention, end anchor = payment slip
- Same prohibitions (no bisecting, no floating bubbles, no metadata stripping)
Example 2: Input: "Adapt this system for harassment evidence in Facebook Messenger." Output: Same architecture, taxonomy adds "reaction emoji" and "reply-quote" objects; keyword dictionary shifts to threatening/abusive language markers; start anchor = first offensive message, end anchor = last message in the harassment thread or a natural conversation break; prohibitions unchanged (context buffer especially critical here to prove escalation pattern).
- Always separate the architecture (detection → OCR → anchor → crop) from the domain keyword dictionary — make the dictionary a swappable config, not hardcoded logic.
- Design anchor detection as a decision tree with confidence scores, not a single keyword match — require corroborating signals (e.g., keyword + adjacent slip image) before auto-cropping.
- Always default to a human-in-the-loop fallback: if anchors are ambiguous or contrast is poor, flag for manual confirmation rather than guessing.
- Log every detected bbox and anchor decision — this audit trail supports Chain-of-Custody arguments in legal contexts.
- Treat the contextual buffer (1–2 bubbles before/after) as a non-negotiable default, not optional.
- Do not treat this as a pure computer-vision cropping problem — semantic/legal correctness (context, chain-of-custody) matters more than pixel precision.
- Do not hardcode financial keywords as the only use case — the same pattern generalizes to harassment, contract, or custody-dispute evidence; keep the dictionary abstracted.
- Do not allow the system to silently drop low-confidence OCR bubbles from the crop — either include them with a confidence flag or halt for human review.
- Do not compress/stretch cropped bubbles to fit a canvas — this can be challenged as evidence tampering.
- Do not conflate "start of visible chat" with "start anchor" — the anchor must be the semantically meaningful transaction/event start, not just the first message on screen.