transform-remove-background-with-transloadit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Inputs

输入项

  • Absolute path to a local input image
  • Optional output path; default to an explicit sibling
    .png
  • 本地输入图片的绝对路径
  • 可选输出路径;默认生成同级的指定
    .png
    文件

Prepare Instructions

准备步骤

Resolve credentials in this order:
  • Shell environment variables
  • The current working directory
    .env
    only
  • ~/.transloadit/credentials
If your
.env
lives in a parent directory, export the variables into the shell first.
Create
steps.json
in the current working directory.
Important:
  • For the current CLI, the file passed to
    --steps
    must be a flat object keyed by step name.
  • Do not wrap the steps under a top-level
    "steps"
    key.
json
{
  ":original": {
    "robot": "/upload/handle"
  },
  "background_removed": {
    "use": ":original",
    "robot": "/image/bgremove",
    "format": "png",
    "result": true
  }
}
按以下顺序获取凭证:
  • Shell环境变量
  • 仅当前工作目录下的
    .env
    文件
  • ~/.transloadit/credentials
如果你的
.env
文件位于上级目录,请先将变量导出到Shell中。
在当前工作目录创建
steps.json
文件。
重要提示:
  • 对于当前版本的CLI,传递给
    --steps
    的文件必须是按步骤名称作为键的扁平对象。
  • 不要将步骤包裹在顶层的
    "steps"
    键下。
json
{
  ":original": {
    "robot": "/upload/handle"
  },
  "background_removed": {
    "use": ":original",
    "robot": "/image/bgremove",
    "format": "png",
    "result": true
  }
}

Run (Local Input Image)

运行(本地输入图片)

bash
npx -y @transloadit/node assemblies create \
  --steps ./steps.json \
  -i ./input/source.jpg \
  -o ./out/result.png
Replace
./input/source.jpg
with your real input image path when needed.
After the command finishes, confirm the PNG exists at the expected output path.
bash
npx -y @transloadit/node assemblies create \
  --steps ./steps.json \
  -i ./input/source.jpg \
  -o ./out/result.png
必要时将
./input/source.jpg
替换为你的实际输入图片路径。
命令执行完成后,确认PNG文件已存在于预期的输出路径。

Debug If It Fails

失败时调试

bash
npx -y @transloadit/node assemblies get <assemblyIdOrUrl> -j
Notes:
  • Keep
    format: "png"
    so the downloaded output preserves transparency.
  • Prefer
    ~/.transloadit/credentials
    as the default fallback when you want a reusable user-level setup.
  • A current-directory
    .env
    still takes precedence, so avoid it when deterministic account selection matters.
  • If credentials only exist in a repo-root
    .env
    , run the command from that directory or export the variables first.
  • Prefer an explicit PNG filename like
    ./out/result.png
    . With the current CLI, using a directory output for a single result may preserve the input path instead of giving you a
    .png
    filename.
  • Prefer a clear foreground subject photo; background removal quality depends on the source image.
bash
npx -y @transloadit/node assemblies get <assemblyIdOrUrl> -j
注意事项:
  • 保留
    format: "png"
    ,这样下载的输出文件会保留透明效果。
  • 如果你需要可复用的用户级配置,优先使用
    ~/.transloadit/credentials
    作为默认备用选项。
  • 当前目录下的
    .env
    仍具有更高优先级,因此当需要确定账户选择时,请避免使用它。
  • 如果凭证仅存在于仓库根目录的
    .env
    中,请从该目录运行命令,或先导出变量。
  • 优先使用明确的PNG文件名,如
    ./out/result.png
    。在当前版本的CLI中,对单个结果使用目录输出可能会保留输入路径,而不是生成
    .png
    文件名。
  • 优先选择前景主体清晰的照片;背景移除的质量取决于源图片。