SuperAPI AI Directory

platform-compliance

General & other

View repository

Updated 10-16 06:18

About this skill

platform-compliance — pre-listing compliance validation

Whether an image looks good is one thing,whether the platform accepts itis another.

This skill only answers the latter: will this image be rejected after upload, which rule does it fail, and how to fix it.

Division of labor with detect-task : detect-task uses a vision model to judge "does it look real", which is subjective and costs compute; this skill reads pixels to make objective determinations, costs no compute, is millisecond-level, and its conclusions are reproducible.Only passing both counts as ready to run.


Generated effect example

Take this repository's flat-lay actual output image and check it against Amazon main image rules:

python3 scripts/check_listing.py docs/flat-lay/example-output.jpg --platform amazon

Real output

docs/flat-lay/example-output.jpg  ·  Amazon 主图  ·  有驳回风险
  1024×1536 JPEG 0.25MB · 背景 RGB(208, 208, 208) · 主体占比 100.0%

  ! 分辨率              最长边 1536px,达标但不足以触发放大镜
  ✓ 画面比例             1024:1536
  ✗ 纯白背景             边缘仅 0.0% 为纯白,背景基色约 RGB(208, 208, 208)
  ✓ 主体占比             包围盒占画面 100.0%
  ✓ 透明通道             无 alpha
  ✓ 边框               无描边
  ✓ 文件格式             JPEG
  ✓ 文件体积             0.25 MB
  ✓ 色彩模式             RGB
  ? 文字 / 水印 / 拼图     像素层判不了,交给 detect-task 或人工过一眼

To the naked eye this image looks like a "light gray studio-shot background", very clean, but Amazon main images require exact RGB(255,255,255), and a gray of 208 will be judged non-compliant. Problems like this are almost impossible for the human eye to spot, while machine inspection gives a conclusion in one second.

One-click fix:

python3 scripts/check_listing.py docs/to-3d/example-output.jpg --platform amazon --fix out/
out/example-output-fixed.jpg  ·  Amazon 主图  ·  通过
  1600×1402 JPEG 0.50MB · 背景 RGB(255, 255, 255) · 主体占比 85.1%

Press the white background → rebuild the canvas at an 85% target → upscale to 1600px → save as compliant JPEG, all in one step.


1. Capability boundaries

Can do Description
Objective spec determination Background purity, subject proportion, resolution, aspect ratio, alpha channel, stroke, format, file size, color mode
Multi-platform rules Amazon / TikTok Shop / Temu / Shopee / Shopify / Taobao, customizable
Automatic repair Press the white background, rebuild the canvas at the target proportion, upscale resolution, compress to the file size limit
Batch Upload multiple images at once, or work with batch-image to process a whole batch
Exit code 0 = ready to run; 1 = rejection risk, convenient for wiring into CI or pipelines
Cannot do Where to go
Judge whether there is text / watermark / collage detect-task 's vision model
Judge whether the product is broken detect-task
Remove watermark remove-watermark
Retouch, remove wrinkles item-repair

Boundaries of automatic repair:--fix only performs compliance-ization at the geometric and color level; it will not retouch for you. If the original image itself is blurry, broken, or watermarked, after repair it will still be blurry, broken, or watermarked.


2. Platform rules

Platform Pure white background Longest side (minimum / recommended) Subject proportion Aspect ratio File size limit
amazon Yes 1000 / 1600 ≥ 85% Unlimited 10 MB
tiktok-shop No 800 / 1600 ≥ 60% 1:1 or 3:4 5 MB
temu Yes 800 / 1350 ≥ 70% 1:1 3 MB
shopee No 500 / 1024 ≥ 55% 1:1 2 MB
shopify No 1024 / 2048 Unlimited Unlimited 20 MB
taobao Yes 800 / 1200 ≥ 70% 1:1 3 MB

Platform rules change. The table above is a machine-checkable subset; refer to each platform's latest official documentation. If you need to use your own criteria, write a JSON and pass it in with --rules ; for field descriptions see references/platform-specs.md。


III. Tool Invocation

# 单张
python3 scripts/check_listing.py main.jpg --platform amazon

# 整批 + 机器可读
python3 scripts/check_listing.py out/*.jpg --platform temu --json

# 校验并自动修复到 fixed/
python3 scripts/check_listing.py raw.png --platform amazon --fix fixed/

# 自定义规则
python3 scripts/check_listing.py main.jpg --platform amazon --rules my-rules.json

Depends only on Pillow:

pip install Pillow

Parameter Conventions

Parameter Value Reason
--platform Target platform Determines which threshold set to use, default amazon
--json Add when integrating into a pipeline Output structured results, including the measured value and threshold for each item
--fix <dir> Add when you want automatic fixes Save the output separately, without overwriting the original image
Exit code 0 / 1 Non-zero when there is a rejection risk, convenient for && chaining

IV. Execution Flow

  1. Confirm the platform. If the user hasn't said, ask, or default based on the store's main battlefield (cross-border → amazon, domestic → taobao)。
  2. Check first, then fix. Run a validation directly without --fix and read the problems out to the user— some problems (such as insufficient subject proportion) will crop the image when fixed, so the user needs to know first.
  3. Distinguish two types of problems:
    • Geometry / color type (white background, proportion, resolution, file size) → --fix can solve it.
    • Content type (watermarks, text, product corruption) → go back to the corresponding generation or retouching skill and redo it.
  4. Recheck after fixing。--fix After that, the script will automatically check the output again to confirm it really passes.
  5. Connect back to the generation side. When it repeatedly fails compliance, write the constraints into the prompt instead of fixing after the fact every time: see "Front-loading Compliance into Generation" below.

V. Front-loading Compliance into Generation

Fixing after the fact is not as good as getting it right in one generation. Appending these sentences to the end of the generation prompt can significantly reduce the non-compliance rate:

Goal Append sentence
Pure white background Pure seamless white background, RGB 255,255,255, no gradient, no vignette, no shadow cast on the backdrop.
Subject proportion The product fills at least 88% of the frame, tight crop, minimal empty margin on all sides.
No text watermark No text, no logo, no watermark, no inset images, no borders anywhere in the frame.
Square image Square 1:1 composition, product centered.

run_loop will automatically do this: when compliance validation fails, it appends the corresponding sentence above to the prompt and runs another round, without human intervention.


VI. Common Problems

Symptom Cause What to do
Looks pure white to the eye, but machine inspection says it isn't Studio-shot light gray wall (RGB 200–245) or slight gradient --fix Press to white, or add the constraint sentence from the table above during generation
Subject proportion is always insufficient Too much blank space left during generation Write in the prompt tight crop; or --fix reconstruct the canvas
PNG turns into a black background after upload The transparent channel is converted to black by the platform Always flatten to a white-background JPEG,--fix will do it automatically
After fixing, the proportion is still a bit off On square-image platforms, the proportion of long-strip products has a physical upper limit The script has already taken the achievable upper limit; accept it, or switch to a slot on a non-square-image platform
The text watermark item is always ? The pixel layer cannot detect it Leave it to detect-task, or have a human take a look

Tips

  • Integrate it into CI:check_listing.py out/*.jpg --platform amazon If the exit code is non-zero, block it, which is more reliable than manual spot checks.
  • Check one image first, then run the whole batch: before generating the whole batch, run one image through compliance to save rework on the entire batch.
  • Different slots have different rules: Main images strict, detail images loose. Don't use the main image's threshold to restrict detail page images.