Implement computer vision solutions 3.1 Design and implement image- and video-generation solutions

A furniture app edits room photos with the Image Edit API on a GPT-image model, replacing…

Study guide skill: Configure image-editing workflows, including inpainting, mask-based edits, and prompt-driven modifications

Question B7-004

A furniture app edits room photos with the Image Edit API on a GPT-image model, replacing only the sofa. The developer builds the mask as a JPEG of the same size as the photo, with the sofa painted black and everything else white. Edits change the wrong areas. How should the mask be built?

Select one answer.

  • A As a PNG with the same dimensions as the photo, where the sofa area is fully transparent (alpha of zero) ✓ Correct answer
  • B Keep the black-and-white mask and set input_fidelity to high so the model knows which area to change
  • C As a JPEG cropped to the sofa's bounding box, so it covers only the area to change
  • D As a base64 string in a JSON request body instead of a file in the form data

Answer: A

The mask marks the area to edit with fully transparent pixels (alpha of zero), and it must be a PNG with the same dimensions as the input image, so a black-on-white JPEG doesn't define the edit area. The Image Edit API takes multipart/form-data, not JSON. input_fidelity controls how closely the output matches the style and features of the input images; it doesn't mark the edit area.

Deep dive

How it works

The Image Edit API modifies existing images based on text prompts. The call is similar to an image generation call, but you also provide an input image. To change only part of the picture, you add a mask. The mask defines the area to edit with fully transparent pixels (alpha of zero), and it must be a PNG with the same dimensions as the input image.

So a black-and-white JPEG mask doesn't fit the rules: the mask must be a PNG, and the edit area is marked by transparent pixels, not black ones. Build the mask as a PNG the same size as the room photo, make the sofa's pixels transparent, and keep the rest opaque.

Other request details worth knowing: the Image Edit API takes multipart/form-data, not JSON. You can provide up to 16 input images, each under 50 MB and in PNG or JPG format. The image editing endpoint is generally available.

The other options, and when you'd use them

  • Keep the black-and-white mask and set input_fidelity to high: input_fidelity controls how closely the model matches the style and features, especially faces, of the input images. It helps with subtle edits, but it doesn't define the edit area. It also isn't supported by gpt-image-1-mini.
  • A JPEG cropped to the sofa's bounding box: The mask must be a PNG with the same dimensions as the input image, so a cropped JPEG fails on both counts.
  • A base64 string in a JSON body: The Image Edit API takes multipart form data, not JSON.

Exam tip

For a mask, think "PNG, same size, transparent where you want changes". Black-on-white or cropped masks are the usual distractors.

References

Last reviewed:

Ready to test yourself? The quiz asks this and every other AI-103 question, with instant feedback. Practice this in a quiz →

All Computer vision questions · AI-103 study guide

Thanks for your feedback!