I wanted Tab completion for photo editing: revisiting a GPT-4o canvas prototype

April 10, 2025

I draw a box around a camel in a desert photograph. A Tab key icon appears beside the box, followed by a suggestion in gray: “Turn this camel into a desert elephant.” I change the suggested animal to a penguin. Once the penguin appears on the sand, I box its feet. The canvas suggests the next edit: add a trail of footprints behind it.1

A rectangle surrounds a large camel in a desert photograph. Below it are a Tab key, an arrow pointing at the camel, and an English suggestion to turn it into a desert elephant.

My prototype, recorded on April 10, 2025, at 03:13. I cropped the empty space around the canvas. The first suggestion is still on screen.

The name I gave the video included “Cursor for Image.” I like the moment when I press Tab in Cursor: the caret sits somewhere, the editor guesses what I want to write next, and one glance tells me whether to accept. After playing with GPT-4o image editing, I thought pictures could have that kind of cursor too.1

What does the cursor point to when editing a photo?

If I type “replace it with a sports car” in a chat, the model still needs to know which car I mean. There are several on the street, and the buildings behind them are in the same photograph. Drawing a box saves me a description of the location. The text beside it says how I want to change it. The first suggestion in the street demo specifies both what to replace and what to preserve: change the yellow taxi into a red sports car, keeping the head-on view and the street's perspective. Only when I select the brick building does the suggestion change to replacing it with a glass tower.

Originally I wanted to skip drawing the box too. I imagined hovering over the car, letting a segmentation model identify its pixels, and guessing a possible edit using the edits I'd already made. In the version I could record, I specified the object with a rectangle. The suggestion appeared when I released the mouse, and Tab accepted it. The fact that the elephant in the recording became a penguin shows why the suggestion text belongs on the canvas: I can see how the tool interpreted the image before deciding whether to go along with it.

Was the GPT-4o image generation API available when I made the demo?

This was the question I specifically investigated on April 1. By then I could upload an image in the ChatGPT web interface and keep editing it over successive turns. I searched for gpt4o image gen api and opened the developer community. The second post quoted the OpenAI announcement: “with access rolling out in the next few weeks.” I wanted the same editing capability I'd just used on the web. OpenAI didn't release it to API developers as gpt-image-1 until April 23, thirteen days after I recorded the demo.234

On April 5 I also looked at another tool that used a canvas selection as input. It sent selected sketch strokes to a model and returned a 3D object you could rotate. See How a whiteboard sketch becomes a rotatable 3D model.

I split understanding the selection from generating the resulting image. On the evening of April 9, I read OpenAI's image input guide, first checking how to send a Base64-encoded image and then switching to the JavaScript example.5 In the prototype I connected to local Ollama. I wanted to pass the selected part of the Excalidraw canvas to llava-phi3 and ask it to describe the contents. Ollama's JavaScript example puts images in the message's images array.6

When I sent the image, describeImage reported illegal base64 data at input byte 4. I searched for that error together with App.tsx:237:15 and landed on a Go question on Stack Overflow. The questioner's string started with data:image/png;base64,, just like the output of toDataURL('image/png') from my canvas. Before the comma are the image format and encoding declaration. The encoded image begins after the comma. When the entire string goes into a Base64 decoder, the first four letters, data, are all valid. The colon immediately after them is the first invalid character. Counting from zero puts it exactly at byte 4.7

The selected image had two uses in the code. To let the browser download the PNG, I assigned the complete data URL to a link's href. When sending it to Ollama, I used describeImage(dataUrl.split(',')[1]), putting only the part after the comma in images.

I wrote separately about choosing the canvas library and why cropping required transforming coordinates in Choosing between tldraw and Excalidraw for a commercial React canvas.

Where did the car and penguin in the recording come from?

On the evening of April 9 I searched for street scenes with cars, downloaded a photo of a food truck on a Manhattan street, and looked for desert and camel images. After 11 p.m. I changed my search from street pictures to free street pictures. When I recorded the next day, the street scene lent itself to two selections in a row: change the nearby taxi while retaining the building behind it, then select the building and change it separately. The surviving search and download records only trace the materials back to that evening.8

To get the demo out quickly, I took screenshots by hand, uploaded them to the ChatGPT web interface, generated the next image with prepared edit instructions, and saved the results. The street and desert scenes each had local JSON containing the demo prompts, images, and canvas positions. When I boxed the car, viewers could see exactly where beside it the suggestion appeared. When the red sports car replaced it, the picture could land in its original position.

Clicking Generate Image made the frontend fetch the next saved image from the current scene. The recorded version used setTimeout to wait a random 20 to 40 seconds before putting the picture back on the canvas. This needed two steps. addFiles(show.files) gave the image contents to Excalidraw. The image element in the scene referred to those contents by fileId and stored the position and size. When I updated the elements with updateScene, I set the new picture's x and y coordinates to the old picture's position. That kept the street scene in place as the taxi turned into a sports car.9 I generated the images in advance in the web interface. The wait after clicking the button was simulated. That's why the recording could show two rounds of editing even though the code couldn't yet take an unfamiliar photo and do the same thing from scratch.

After making the video, I had something specific to show: which object the suggestion appeared beside, exactly what pressing Tab accepted, and what the next picture looked like after I changed my mind. Could a model look at a selection and a few previous edits and make a suggestion I'd genuinely want to accept with Tab? Two scripted demos couldn't answer that. It was precisely the next question this little canvas left me with.

Footnotes

  1. Cai, B. (2025, April 10). Forget ComfyUI I have created of Cursor for Image [Demo video]. YouTube. Desert scene, from about 03:13. Screenshot from the author's retained recording of that day. ↩ ↩2

  2. OpenAI. (2025, March 25). Introducing 4o Image Generation. OpenAI. Multi-turn generation. ↩

  3. _j. (2025, March 27). API for image generation for gpt-4o model [Post 2, quoting the launch announcement]. OpenAI Developer Community. Original reply. ↩

  4. OpenAI. (2025, April 23). Introducing our latest image generation model in the API. OpenAI. Paragraph 2, release date added in retrospect. ↩

  5. OpenAI. (n.d.). Images and vision. OpenAI API Docs. On April 9, 2025, I visited the Base64 example in the old image guide. See now image inputs in the newer guide. ↩

  6. Ollama. (2024, February 2). Vision models. Ollama Blog. JavaScript image input example. ↩

  7. icza. (2015, June 24). Illegal base64 data at input byte 4 when using base64.StdEncoding.DecodeString(str) [Answer]. Stack Overflow. Data URL format and decoding example. I found this question on April 9, 2025, at 21:59. That evening's 22:10 prototype commit b486525 retains the selection export and model call in src/App.tsx, lines 225–242. ↩

  8. Google. (2025, April 9). free street pictures [Image search history]. Original query from that evening. Date from an old local browser tab and image downloads from the same evening. ↩

  9. Excalidraw. (n.d.). excalidrawAPI. Excalidraw Docs. Arguments and purpose of addFiles. The prototype calls addFiles followed by updateScene in the April 10 commit 96319df, lines 603–616 of src/App.tsx. ↩

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-04-10). I wanted Tab completion for photo editing: revisiting a GPT-4o canvas prototype. https://caiborui.com/blog/2025-04-10-zh-gpt-4o-image-editing-copilot-entrans

@misc{borui2025-c0dcd104,
  author = {borui},
  title = {{I wanted Tab completion for photo editing: revisiting a GPT-4o canvas prototype}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-04-10-zh-gpt-4o-image-editing-copilot-entrans}
}