From a CometAPI image to web derivatives: resize a saved master with sharp

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:

  1. Take the approved edit result’s data[0].b64_json and decode the base64 into image bytes.
  2. 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.
  3. Pass the master bytes as inputBuffer to sharp. Write each delivery asset under a separate name, such as card-320x240.webp; never use the master’s path as the derivative output.
  4. 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.

I would add a two-stage acceptance test so a delivery failure does not automatically become a verdict on the image-edit model.

First, assess the saved CometAPI edit result against the creative brief before running sharp: is the requested edit present, and is the content that must survive into each placement actually there? Then assess each derivative against a placement-specific checklist. For a product card, for example, that might require the whole product to remain visible and a particular label to be readable at the displayed size. These are proposed checks, not reported test results.

Record failures separately:

  • Master fails the creative brief: reconsider the edit request or source material; this is not yet a derivative-processing question.
  • Master passes, derivative fails: inspect the local transformation and placement requirements before requesting another model output.
  • Both pass: accept that derivative for that placement, without extending the conclusion to other sizes.

That distinction matters if this workflow later becomes a model comparison. A comparison of final web assets should record both master acceptance and derivative acceptance, with the same placement criteria and declared transformation settings. Otherwise, a final pass/fail score leaves it unclear which stage needs improvement. The Topic’s cited sharp example supplies a transformation recipe, not evidence that a model preserved readable detail or that local resizing matches a fresh generation.