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 (but not all that often) I like to use animated GIF clips.
Both AVIF and WEBP can act just like animated GIFs.
AVIF first, WEBP second:
(If you're wondering what this is from, see this. I think it's a neat show.)
The AVIF is 38.8 KiB (39.7 kB) and the WEBP is 133.4 KiB (136.6 kB).
Obviously, AVIF really shines here. Both the AVIF and WEBP are the same clip, same length, same frame rate, same dimensions. On top of the AVIF being significantly smaller, it also looks better with less artifacts. Look at the blue sky in the clip. The WEBP blotches up a bit while the AVIF didn't blotch up at all.
AVIF should be replacing the ancient animated GIF right now because it is just that much better.
And how big would the GIF have been for the above clip? At the same dimensions and frame rate, 550.1 KiB (563.3 kB) for a low quality version and 1,024 KiB (1,048 kB) for high quality.
In this instance, AVIF is 71% smaller than the WEBP, 93% smaller than the low-quality GIF, and 96.2% smaller than the high-quality GIF.
To put this in perspective, I had to shrink the dimensions and cut the frame rate in half for the GIF just to get it to the same size as the WEBP.
Same above clip as GIF with half the frame rate and reduced size to achieve the above WEBP file size:
And then I had to shrink it down even more to get it to the file size of the AVIF.
Same above clip again as GIF with half the frame rate and even more size reduction to achieve the AVIF file size:
AVIF just rules the roost here without question.
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.
Published 2025 Mar 18