battle of the image formats (jpg jxl webp avif heic)
I recently did a massive reorganization of all my backups, which included thousands of JPG files I had to move around.
The JPG image format has been around for over 30 years. Yeah, that long. JPG goes all the way back to 1992. As old as it is, it's still the best image format. However, I wanted to see if the newer formats available were any good, so I did some tests, and here's what I came up with.
I'll first note that I had to hunt around to find the right tool that would support ALL the newer formats for mass conversion. I found one for Linux with the command line tool vips. This is also available for Windows and Mac from libvips.org.
Even though vips supports conversion from JPG to JXL, WEBP, AVIF and HEIC, one of them didn't exactly work correctly, and I'll detail which in a moment.
I need to explain a few things first.
Why switch formats?
There's only one answer, to save space.
When you start filling up a memory card on a phone or digital camera with hundreds of images that turns into thousands later, that cumulatively ends up being gigabytes of data that you have to move elsewhere at some point. And never mind video, because this is just photos I'm talking about.
It's always a good thing whenever you can size data down without losing anything, and that's what I'm concentrating on here. The less space photos take up, the less often you have to buy more storage.
What are these formats?
JPEG XL is developed by Joint Photographic Experts Group (yes, that's where JPEG comes from).
WebP is a format developed by Google.
AVIF is AV1 Image File Format, developed by the Alliance For Open Media a.k.a. AOMedia or just AOM. The founders of AOM are Amazon, Cisco, Google, Intel, Microsoft, Mozilla and Netflix, and they're headquartered in Wakefield, Massachusetts.
HEIC is High Efficiency Image File Format. This was developed by the Moving Picture Experts Group, a.k.a. MPEG. If you use an iPhone, you probably recognize HEIC since Apple has had support for this since iOS 11.
The test
I took three photos from a Canon PowerShot ELPH 360 HS I have, and using the vips tool on the command line like this:
vips copy image.jpg image.avif
...converted the original high-quality JPG files. I did a run of each for JXL, WEBP, AVIF and HEIF (HEIC would be the same thing).
The test results
This is what happened:
The total size of the 3 original JPG files was 20.4 MiB (21.4 MB).
HEIF got the total size down to 4.9 MiB (5.12 MB).
JXL got the total size down to 2.9 MiB (3.04 MB).
WEBP got the total size down to 2.5 MiB (2.62 MB).
AVIF got the total size down to 1.2 MiB (1.26 MB).
Said another way, HEIF reduced the 3 file sizes combined by 76%, JXL by 86%, WEBP by 88%, and AVIF by 94%.
Yeah, AVIF blew all the other formats out of the water. And bear in mind this is using the stock vips 'copy' with no adjustments. Nice.
HOWEVER... as with all things, there are pros and cons.
AVIF performed the best but was the slowest to process.
This is an example command of what I used for batch conversion:
for i in *.JPG;do vips copy "$i" "${i%%.*}.avif";done
The slowest conversion time was JPG-to-AVIF, and the fastest was JPG-to-WEBP. So while AVIF saves the most space, it takes the most time to convert. Also, WEBP by far blows everything out of the water for speed of conversion.
BUT HANG ON, there's more.
Let's talk about the EXIF data. As in that stuff in an image that states the camera used, camera settings, maybe GPS coordinates if the photo contains them, and so on.
With the vips tool, JPG-to-AVIF kept all the EXIF stuff. JPG-to-HEIF, also a yes. JPG-to-WEBP, again, yes. But for JPG to JXL, no. With JPG-to-JXL, all of the image was there, but the EXIF data got wiped out.
Yes, there is a thing called ExifTool where you can extract the data out of a JPG, save it elsewhere, then place it into a JXL later. I'm certain this could be automated using a Linux script but didn't bother to try it.
What I wanted was a one-liner solution on the command line that did a mass conversion from one image format to the other and kept all the EXIF data. Vips does that for AVIF, HEIF and WEBP, but not JXL. Why? I have no idea.
Due to the fact I don't have a one-liner way of convert-and-keep-EXIF for JPG-to-JXL, I can't use JXL.
In my specific situation...
...the two best image formats for me to convert to if I wanted to save space would either be AVIF or WEBP.
Which to choose? That's a tough call, but for the way I use images, AVIF is the better choice even though the wait time for conversion is longer.
And then there's the whole video clip thing
Being I've been using the internet a long time and I run a web site, sometimes I like to use animated GIF clips.
Both AVIF and WEBP can act just like animated GIFs.
I made a 300x168 10fps video clip from a video I recorded with my phone. FFMPEG was used to convert MP4 to AVIF and WEBP.
WEBP first, AVIF second:
The WEBP is 262,840 bytes and the AVIF 25,390 bytes. Not a typo.
Obviously, AVIF really shines here. Both the AVIF and WEBP are the same clip, same length, same frame rate, same dimensions. But the AVIF is much smaller.
AVIF should be replacing the ancient animated GIF right now because it is just that much better.
To put this in perspective, I had to shrink the dimensions for the GIF to be the same file size as the WEBP.
Here is the same above clip as GIF with reduced size to achieve the file size of the WEBP (not down to the byte but close):
That GIF already looks terrible, but I had to shrink it down a crazy amount to get it to the file size of the AVIF.
Same above clip again as GIF with size reduced more to match the file size of the AVIF:
At that tiny size it's not even worth bothering with.
For those that know GIFs, if you're thinking "just reduce size and frame rate", that barely helps at all because the end result is still terrible.
If I reduce size by half AND reduce frame rate by 50% to just 5fps, this is the crappy GIF you get as a result:
...and it's 88,617 bytes. And no, reducing colors doesn't help either. No matter what, it's still nowhere near as compact as an unoptimized AVIF.
What's an optimized AVIF? I can get the original video clip converted to AVIF with a final file size of 13,318 bytes and it still works.
Here it is:
That is what I mean by an optimized AVIF. I could get the file size even smaller but then the frames start to "mush" together too much.
You may be thinking there's no way the image above is just 13,318 bytes. It is. Sure, it blurs a little bit, but the point is I can reduce file size without decreasing colors nor frame rate nor image dimensions.
AVIF just rules the roost without question. It not only beats GIF but obliterates it.
Worth it to convert image formats?
It is where storing photos is concerned because the storage space savings cannot be ignored.
I look at all the JPG files I have (which is many), and think wow, I could cut the file size down by... a lot.
I was able to get a 90%+ reduction in file size for high quality digital camera photos easily. But I did one better. I purposely created a crusty JPG at 30% quality, ran a vips JPG-to-AVIF conversion, and was still able to shave off another 30% of the file size. This is impressive to me because the conversion with file size reduction will even work on already-compressed-to-hell crusty JPG files. Yeah, the image will still be crusty after conversion, but look the same and with smaller file size.
The only thing that sucks is that conversion has to take place before backing up image files. Everything I use to take photos with all write files as JPG with no option to choose anything else. But that's a minor annoyance at best considering the space saved by using AVIF.
I've not made the decision whether to switch to AVIF for my backups, but I might, because yeah, it's that good.
❤️ Like this post? Leave a tip
Published 2025 Mar 18