Amazon Listing Image Optimizer
Automatically fix non-square product images on Amazon listings — download, pad to 2000×2000 white background, and push back to live listings via SP-API. No manual Seller Central work required.
Why This Exists
Amazon penalizes listings with non-square images (aspect ratio != 1:1). Common offenders:
- - Landscape 16:9 or 4:3 product shots
- Portrait hero images
- Tiny low-resolution images
This skill detects, fixes, and re-uploads — all automatically.
Setup
1. Install dependencies
CODEBLOCK0
2. Create SP-API credentials file
{
"lwaClientId": "amzn1.application-oa2-client.YOUR_CLIENT_ID",
"lwaClientSecret": "YOUR_CLIENT_SECRET",
"refreshToken": "Atzr|YOUR_REFRESH_TOKEN",
"region": "eu",
"marketplace": "YOUR_MARKETPLACE_ID",
"sellerId": "YOUR_SELLER_ID"
}
Set
AMAZON_SPAPI_PATH env var to point to it (default:
./amazon-sp-api.json).
Scripts
audit.js — Detect non-square images
node scripts/audit.js --sku "MY-SKU" # audit single SKU
node scripts/audit.js --all # audit all FBA SKUs
node scripts/audit.js --all --out report.json # save report
Outputs: list of non-conforming image slots with dimensions.
pad_to_square.py — Fix images locally
# After audit.js downloads originals to ./image_fix/
python3 scripts/pad_to_square.py ./image_fix/
Pads all
*_orig.jpg files to 2000×2000 white background, outputs
*_fixed.jpg.
push_images.js — Upload fixed images to Amazon
node scripts/push_images.js --dir ./image_fix/ --sku "MY-SKU" --slots PT03,PT05
Spins up a local HTTP server on a public port, submits image URLs to SP-API, then auto-kills the server after 15 minutes (time for Amazon to crawl).
fix_title.js — Patch listing title
node scripts/fix_title.js --sku "MY-SKU" --title "New optimized title here"
Full Pipeline (one command)
node scripts/audit.js --all --out report.json
python3 scripts/pad_to_square.py ./image_fix/
node scripts/push_images.js --dir ./image_fix/ --from-report report.json
Image Slot Reference
| Slot | Attribute | Description |
|---|
| MAIN | INLINECODE8 | Hero image (must be white bg) |
| PT01–PT08 |
other_product_image_locator_1 …
_8 | Secondary images |
Notes
- - Amazon processes image updates within 15–30 mins of ACCEPTED response
- VPS must have a publicly accessible IP/port for the temp HTTP server (or use S3/Cloudflare)
- PIL uses LANCZOS resampling for best quality when resizing
- Keep images under 10MB; target 2000×2000px @ 95% JPEG quality
Related
Amazon Listing Image Optimizer
自动修复亚马逊商品列表中非正方形的产品图片 — 下载、填充为2000×2000白色背景,并通过SP-API推回至在线商品列表。无需手动操作卖家中心。
存在原因
亚马逊会对非正方形图片(宽高比 != 1:1)的商品列表进行处罚。常见违规情况:
- - 横向16:9或4:3的产品照片
- 纵向主图
- 低分辨率小图
此技能可自动检测、修复并重新上传。
设置
1. 安装依赖
bash
pip3 install Pillow
npm install amazon-sp-api
2. 创建SP-API凭证文件
json
{
lwaClientId: amzn1.application-oa2-client.YOUR
CLIENTID,
lwaClientSecret: YOUR
CLIENTSECRET,
refreshToken: Atzr|YOUR
REFRESHTOKEN,
region: eu,
marketplace: YOUR
MARKETPLACEID,
sellerId: YOUR
SELLERID
}
设置环境变量 AMAZONSPAPIPATH 指向该文件(默认值:./amazon-sp-api.json)。
脚本
audit.js — 检测非正方形图片
bash
node scripts/audit.js --sku MY-SKU # 审核单个SKU
node scripts/audit.js --all # 审核所有FBA SKU
node scripts/audit.js --all --out report.json # 保存报告
输出:不符合规范的图片槽位列表及其尺寸。
padtosquare.py — 本地修复图片
bash
在audit.js将原始图片下载到./image_fix/后执行
python3 scripts/pad
tosquare.py ./image_fix/
将所有 orig.jpg 文件填充为2000×2000白色背景,输出 fixed.jpg。
push_images.js — 将修复后的图片上传至亚马逊
bash
node scripts/push
images.js --dir ./imagefix/ --sku MY-SKU --slots PT03,PT05
在公共端口启动本地HTTP服务器,将图片URL提交至SP-API,15分钟后(亚马逊爬取时间)自动关闭服务器。
fix_title.js — 修改商品标题
bash
node scripts/fix_title.js --sku MY-SKU --title 新的优化标题
完整流程(一条命令)
bash
node scripts/audit.js --all --out report.json
python3 scripts/pad
tosquare.py ./image_fix/
node scripts/push
images.js --dir ./imagefix/ --from-report report.json
图片槽位参考
| 槽位 | 属性 | 描述 |
|---|
| MAIN | mainproductimagelocator | 主图(必须为白色背景) |
| PT01–PT08 |
otherproduct
imagelocator
1 … 8 | 副图 |
注意事项
- - 亚马逊在收到ACCEPTED响应后15–30分钟内处理图片更新
- VPS必须拥有可公开访问的IP/端口用于临时HTTP服务器(或使用S3/Cloudflare)
- PIL在调整大小时使用LANCZOS重采样以获得最佳质量
- 图片大小控制在10MB以内;目标为2000×2000像素,95% JPEG质量
相关