generate(
prompt=(
"Create a studio product photograph of an unbranded teal "
"ceramic travel cup on a warm cream background. "
"Show one cup, a clean silhouette, and a soft contact shadow. "
"No text or decorative objects."
),
destination="cup.png",
output_format="png",
)
generate(
prompt=(
"Design an original minimalist icon of a teal travel cup "
"with a small leaf motif. Use simple closed vector shapes, "
"two flat colors, and generous negative space. "
"No text, gradients, photographs, or background scenery."
),
destination="cup-icon.svg",
output_format="svg",
)
generate(
prompt=(
"Create a single teal ceramic travel cup as an isolated "
"e-commerce asset. Center the entire cup with generous padding. "
"Keep clean edges and a fully transparent background. "
"No floor, backdrop, checkerboard pattern, or text."
),
destination="cup-transparent.png",
output_format="png",
background="transparent",
)
実際の透過を検証します:
from PIL import Image
with Image.open("cup-transparent.png") as image:
alpha = image.convert("RGBA").getchannel("A")
minimum, maximum = alpha.getextrema()
if minimum == 255:
raise RuntimeError("The output contains no transparent pixels.")
if maximum == 0:
raise RuntimeError("The output is entirely transparent.")
print("The output contains visible content and transparency.")
with (
open("product.png", "rb") as product,
open("setting.png", "rb") as setting,
):
response = requests.post(
f"{BASE_URL}/images/edits",
headers=HEADERS,
data={
"model": "gpt-image-2.6-sunburst",
"prompt": (
"Use the cup in the first image as the exact product "
"reference. Use the second image only for the setting. "
"Place the cup naturally in that setting. Preserve its "
"silhouette, lid, color, and printed details. "
"Do not copy other products from the second image."
),
"quality": "high",
"complexity": "medium",
"output_format": "png",
},
files=[
("image[]", ("product.png", product, "image/png")),
("image[]", ("setting.png", setting, "image/png")),
],
timeout=(15, 300),
)
save_result(response, "product-in-setting.png")
with (
open("product-oriented.png", "rb") as source,
open("markup.png", "rb") as markup,
):
response = requests.post(
f"{BASE_URL}/images/edits",
headers=HEADERS,
data={
"model": MODEL,
"prompt": (
"Change the body of the cup inside the red circle "
"to matte cobalt blue. Preserve the lid, shape, "
"lighting, and surrounding scene. "
"Remove the annotation from the finished image."
),
"quality": "medium",
"complexity": "low",
"output_format": "png",
},
files={
"image": ("product.png", source, "image/png"),
"markup": ("markup.png", markup, "image/png"),
},
timeout=(15, 300),
)
save_result(response, "cup-edited.png")