← back

Reducing the space used by DALL-E images by 50%!

13 Jan, 2024

This is related to a certain project which I worked on. As the date of creating this blog, I can’t actually what the actual project is, but this project in some areas required to generate image from AI, speaking more especially OpenAI’s DALL-E.

Everything was going smoothly, we were doing stuff, testing(you heard is right) how we were going. It was good. Out of nowhere my colleague, went to the database where we were keeping track of these images through links, while the images where hosted on a cloud platform. I got a message in which he wanted to know the number of images we had. So as a true programmer, I accessed the cloud platform to check it.

I found more than 200+ images created! We were generating the highest resolution(1792x1024) images from DALL-E . A single image had the size of about ~5MB.

So, 200 images would mean ~1000MB at minimum. For the sake of understanding, let’s say its about 1GB. This would mean we WERE wasting a lot of space and money at this. This became the priority ASAP! We needed to do something!!

We thought of compressing the image and then storing it in another form, but it was not feasible since, we were displaying the images in a gallery like view. And de-compressing and showing n images on web would lead to more cost and bandwidth. So we needed another way…

From this I came upon on idea like, there should definitely some type of file compression technique that is friendly to web and space. On researching, I stumbled on webp. It could convert the images to around 30% smaller from original JPEG or PNG image size.

It was what we needed…

  1. Friendly to web!
  2. Reduces the size by 30%!
  3. Supported on most of the modern browsers!

With this we could save around ~500MB of the space we used and the images would load a lot faster since they are smaller in size!! I big win, we saved 50% of the space and lot of money!!

Note: There are other formats like AVIF (this could reduce the file size upto whopping 50%), but we found webp to be more suitable in our case.