Multiple gpt-image-1 high fidelity edits lead to grainy result

When doing multiple image edits in a row (using the output image as the input for the next batch) eventually after a few edits makes the image super grainy and unusable. Is there a way to avoid this whilst still having a high fidelity edit?

8 Likes

Also getting this!! Would love to have this fixed.

OP are you getting this in responses API or the regular image gen one?

I get it in the regular image edit API..

Curious: is the input to the edits endpoint including multiple images, or are you, in the chat-like screenshot, only sending one image for modification, with the prompt shown, and no previous images before that?

In the latter case, there should be no “history”, just individual generations based on one image, meaning it should just a random chance.

“Responses” doesn’t act like a discrete “tool” that gets sent a prompt, but rather, it scrapes the chat in an undocumented manner, including images. OpenAI must tell us how this works and how much context is considered.

damn i get this in responses API as well

1 Like

Something similar happened yesterday: Using the edits endpoint API, for image modification, with parameter input_fidelity = high.

Original image had two figures. I prompted to add another figure in the background of the original image. Upon consecutive generations with the same prompt (and the same original image), the two original figures began to distort - each generation made the distortion worse and the image background became darker.

I fixed it by adding to the prompt: “Do not modify the two figures or the brightness of the original image.” But it should not have been neccessary in the first place.

A possible solution is if your saving the file as a jpg/jpeg/i think webp? basically anything but png (loseless), everytime you edit it will compress the photo causing grain and artifacts.

You might be outputting the photo from openai as png, but then saving it to r2 or aws as a jpeg, etc. Everywhere it needs to be saved as a png.

Then it wont compress it between edits.

(Modified as the community didnt like that i stated this as a solution, but it did work for me, but not for OP)

1 Like

We are sending a png to be modified (originally created by OpenAI) and still getting distortion as discussed in my previous post.

We store everything in PNG format and this issue still happens. Unless R2 does some magic compression by itself this should be unrelated..

I’ve encountered this problem too. My method is to save the image before the issue appears, then start a new conversation and upload the image for editing. After saving it again, I open another new conversation to upload and edit the image once more. By repeating this cycle, I can get rid of that annoying grainy effect. (Though it’s a rather troublesome method.)

1 Like

hmm that weird.

To be fair i’ve only tested with responses API.

The interesting thing to me is the pending (streaming) images would never have the grain, but the final image would.

So I checked, and they were being outputted as png from open ai, but then saved to r2 as jpeg. Once i switched it all to be png i haven’t got this since.

I would try with responses api, but regardless its highly likely theres multiplied compression happening somewhere.

So a commonality between two reporters is using Cloudflare R2 and reporting on the results delivered from there?

Or is this from a locally-logged image also, a base64 return directly offered to the user?

Seems like the first step is to replicate this locally, log the API response stream including the base64 of images.

Notes about Cloudflare Images:

There are two different ways to use Images:

  • Efficiently store and deliver images. You can upload images into Cloudflare Images and dynamically deliver multiple variants of the same original image.
  • Optimize images that are stored outside of Images You can make transformation requests to optimize any publicly available image on the Internet.

Efficient, Optimize. Resize. Sounds like lots of rewriting of images. Code that might not like the watermark metadata, transparency, or other contents as input, or might damage your file, like dithering the alpha channel.

Also, you can optimize what is sent and resent for files. You can resize sent images so the shorter dimension is maximum 512px, the longer, max 1536, no metadata.

If “high_fidelity”, the additional token cost indicates instead that you would want solely a max 1536px longer dimension. So, the generated images should be directly compatible and optimal with high_fidelity if I infer beyond documentation correctly.

Remember that “auto” instead of “opaque” can send you transparent imagery output to feed back in, and edits also accepts transparency input. Proper code hygiene is needed to preserve the desired alpha channel presence.

On my side, the output image is clearly being stored as PNG, so it should be lossless. I do not do any compression myself, so I am very confused by this.

1 Like

that image is a jpg but im assuming thats just a screenshot or something hahaha

Haha, the community forum converted it to JPEG for me.

That’s a good lead and a good common factor. I am using R2 dev URL’s which might have some additional compressing in some cases I can imagine..

this happens in chatgpt web/desktop app as well. Not just limited to API. I have been seeing it for a couple of weeks now. I mostly work around it, assuming it was a bug and would get fix sooner or later, but the issues persists.

  1. generated photo realistic image from prompt to make the previous generation which was very much a personally undesirable 4o “painterly style” image that looks like everyone else’s images (not an edit, but the second image in the session from a full prompt):

  2. Edit prompt = integrate the biophage into her head anatomy, remove the wings

  3. Edit prompt = add biophage limbs to the mouth region to act as feeders

This happens frequently. Usually starting a new chat session with the previous image is fine, but that’s a work around not a solution.

1 Like

This is especially bad if I edit an image that I have previously asked chatgpt to remove the background and ground around the subject create an transparent image. workaround has been to attach a copy of the image to a prompt instead of an actual inline edit.

I replicated in ChatGPT immediately.

I prompted with the house image above (the forum’s jpeg) that was corrupted, describing the repair needed.

The preview was looking okay, until the final result replaced it, again with the symptom.

A second image generation try gives our house back, reconstructed from the bad image.

It seems this is a universal gpt-4o/imagegen/image-1 fault seen sometimes in the last stage - AI upscaling (and distorting small faces), but with no report of original generations so far.

I imagine one could use a contrast-detection algorithm to signal the bad generations and keep them from the user with a regenerate (the reason I needed more “original” to algorithmically compare to damaged).

Then send the $0.25+ API bill per image to OpenAI for their failures.

1 Like

Update: I tried postprocessing my image and adding a slight blur with sharp on node but that did not stop the issue from happening on the second edit.

1 Like