Klingで画像を拡張する
CometAPI 経由で Kling Image Expansion API を使用し、制御可能なアウトペインティングで画像を元の境界より外側へ拡張します。
拡張率の仕組み
- 各比率は元の幅または高さを基準に測定されます
- 拡張後のキャンバス全体は、Kling のドキュメントに記載された面積制限内に収まる必要があります
- 大きな拡張を試す前に、まずは各辺で
0.1のような小さな値から始めてください
リクエストの流れ
- 4 つの ratio フィールドをすべて送信し、拡張したくない辺には
0を使用します - 返された
task_idを保存します - タスクが終了状態に達するまで、対応する Kling の画像クエリパスをポーリングします
承認
Bearer token authentication. Use your CometAPI key.
ヘッダー
Must be application/json.
ボディ
Source image to expand. Image URL or raw Base64 string without a data: prefix. Supported formats: JPG, JPEG, PNG. Maximum 10 MB, minimum 300x300 px, aspect ratio between 1:2.5 and 2.5:1.
Upward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Downward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Leftward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Rightward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Optional text prompt to guide the expanded area content. Maximum 2500 characters.
Number of expanded images to generate. Range: 1-9.
1 <= x <= 9Watermark options.
Webhook URL for task status notifications.
Optional user-defined task ID for your own tracking. Must be unique per account.