Generated images are not standard PNGs?

If I try to open generated images with Gnome Image Viewer, I usually get a “Not a PNG file” error. However, I can see the image if I open it in GIMP or Firefox.

I’m using the python openai library. I set up image generation like this:

      client = OpenAI()
      response = client.images.generate(
        model="dall-e-3",
        prompt=prompt,
        n=1,
        size='1024x1024',
        response_format='b64_json',
        user=userId
      )
      firstImage = response.data[0]
      imgData = b64decode(firstImage.b64_json)

      with open(f'{IMG_DIR}/{imgId}.png', 'wb') as f:
        f.write(imgData)

.webp

See reference and you can also check the first bytes of the header, that define the mimetype.

1 Like

I have noticed the same thing. When b64_json is decoded, it seems to be in webp format. When I use the response_format as url, the image returned is a PNG.