Hi!

Did anyone else notice large file sizes when generating pictures using the Dalle api?

The same 1024x1024 is 3.1 mb when using the API, compared to ~1.3 mb using the regular DallE website. Also -if I open the 3 mb image and save it as PNG in photoshop, it becomes 1.3 mb as should (and the process is lossless).

Anyone else experience this?

I’m getting this, using OpenAI’s example:
curl https://api.openai.com/v1/images/generations
-H “Content-Type: application/json”
-H “Authorization: Bearer YOUR-OPENAI-KEY”
-d ‘{
“prompt”: “a photo of a happy corgi puppy sitting and facing forward, studio light, longshot”,
“n”:1,
“size”:“1024x1024”
}’

Anyone coming by this - the following code will decode the base64, save it in 100% quality, and save back to base64 - somehow reducing size by 70%

const compressedPictures = await Promise.all(generatedPictures.map(async (picture) => {
const buffer = Buffer.from(picture.b64_json, ‘base64’);
const compressedBuffer = await sharp(buffer).png({ quality: 100 }).toBuffer();
return compressedBuffer.toString(‘base64’);
}));

1 Like

We also observed this behavior.

@luke @logankilpatrick Is there a plan to support compression on DallE api-side (as an additional api parameter)?

2 Likes