An approved image and its web-delivery sizes are two different production decisions. If the picture is already right and the remaining request is “make versions for these placements,” a useful boundary is: save the CometAPI result as an unchanged master, then create the delivery derivatives locally with sharp. Do not treat each delivery dimension as a request for new visual content.
This is a proposed workflow for an image-edit result, not a tested integration or a guide to a general image-generation endpoint.
Make the CometAPI handoff explicit
CometAPI’s Create image edit documentation describes POST /v1/images/edits for editing existing images. For GPT image edit models on that route, it documents inline base64 output and directs callers to read the edited image from data[0].b64_json.
Keep three controls separate:
| Decision | Where it belongs |
|---|---|
| Requested edit-output size | CometAPI’s size field, when supported by the selected model |
| Encoded master image type | CometAPI’s output_format, which controls the image type inside b64_json |
| Web derivative dimensions and format | The local sharp processing step |
For example, the CometAPI page documents output_format: "jpeg" for a JPEG payload. response_format is not the control for choosing that encoded image type. Nor does a desired 320 × 240 web asset establish that the selected model accepts that API output size.
Preserve first, derive second
The sharp project README describes converting images into smaller, web-friendly outputs of varying dimensions. Its buffer-input example combines these operations:
sharp(inputBuffer)
.resize({ width: 320, height: 240 })
.toFile('output.webp', (err, info) => { /* handle completion */ });
The connection to the CometAPI response is an implementation proposal:
- Take the approved edit result’s
data[0].b64_jsonand decode the base64 into image bytes. - Save those bytes unchanged as the master, with a file type matching the encoded payload. Keep a record of the edit request’s size and output format separately from derivative settings.
- Pass the master bytes as
inputBufferto sharp. Write each delivery asset under a separate name, such ascard-320x240.webp; never use the master’s path as the derivative output. - Start each further derivative from the saved master, with its own requested dimensions, rather than overwriting the only approved asset.
Neither source demonstrates that complete handoff. The documentation supports the two ends—CometAPI’s encoded edit output and sharp’s buffer-to-WebP resizing example—not an end-to-end test result.
Where to stop the recommendation
Use this boundary when the requirement is different delivery sizes of the same image. If a placement needs a different composition, a changed subject, or detail absent from the approved master, revisit the creative requirement instead of treating local resizing as the answer.
Before accepting derivatives, inspect the subject’s framing, fine details and any transparency at the actual placement size. The short README example is not a crop/fit specification or a guarantee about upscaling, metadata retention or visual quality. Resolve those requirements explicitly before adopting it as a production preset.
The practical result is a separation of responsibilities: CometAPI produces the approved edit result; local processing prepares its delivery variants. That is not a claim of measured cost or latency savings, and a resized image is not established here as equivalent in quality to a separately generated one.