Replies: 11 comments
-
Hi @goldmerc, Yes, libjpeg-turbo is perhaps 3x to 4x faster on x86, and it's binary compatible, so all you need to do on Ubuntu is "apt install libjpeg-turbo". The file size will hardly change. mozjpeg is not binary compatible. You can get up to perhaps 30% extra compression by adjusting the parameters that it provides. It's not easy to build libvips against mozjpeg -- you'll probably have to build a lot of the dependencies yourself. If you are just interested in small files, HEIC or AVIF are probably better choices. |
Beta Was this translation helpful? Give feedback.
-
Here's a libvips + mozjpeg on ubuntu 18.10 sample build: https://github.com/jcupitt/docker-builds/tree/master/libvips-mozjpeg-ubuntu18.10 |
Beta Was this translation helpful? Give feedback.
-
Thanks @jcupitt. That's very helpful. To use turbo, should you uninstall libjpeg first? and do you need to install turbo before installing libvips? (all using apt-get) I'm happy using apt-get but don't really want to get into building things myself. So sounds like mozjpeg is out. That said, I'll have a play following the dockerfile you suggest when I have some free time. The files are for display on a website so I don't think HEIC or AVIF would be suitable. Btw, when I apt-get install libvips on Ubuntu 18.04, it pulls in firefox, is that correct? |
Beta Was this translation helpful? Give feedback.
-
Yes, just "apt install libjpeg-turbo" and it does everything for you. No need to uninstall or reinstall anything else. Docker makes building things yourself safe and (relatively) easy. It should be a simple way to experiment with mozjpeg anyway. The libvips package on Ubuntu 18.04 is a bit crazy. The one on 20.04 is more reasonable. |
Beta Was this translation helpful? Give feedback.
-
Fantastic. I will try the dockerfile - thanks! I just created a new vm running 20.04. "apt install libjpeg-turbo" says "Unable to locate package". (had the same thing on 18.04) When I search I find libjpeg-turbo8. Is that the one to install? (there is also a dev version and a package called libturbojpeg0-dev) |
Beta Was this translation helpful? Give feedback.
-
ooops, yes, add the 8. You don't need the dev version. |
Beta Was this translation helpful? Give feedback.
-
Cool, so libjpeg-turbo is installed. Is there a way to check that libvips is using the turbo version and not the standard libjpeg? |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
So, i'm using the Laravel Homestead VM. If I run "apt search libjpeg-turbo" I get the following...
Which seems to suggest that both libjpeg and libjpeg-turbo are installed? |
Beta Was this translation helpful? Give feedback.
-
That's correct -- many programs depend on libjpeg, and they have to continue to work after you swap it out for libjpeg-turbo. The residual libjpeg package is just there to keep them happy. Try some benchmarks: you should see a nice speedup. |
Beta Was this translation helpful? Give feedback.
-
Perfect! Thanks for your help and patience! ;-) |
Beta Was this translation helpful? Give feedback.
-
Some newbie questions -
The docs recommend using libjpeg-turbo "if you can". Is there any benefit over using libjpeg except speed? So, if you use the same settings, is the image identical? And the only difference is how quickly the operation is completed? As far as I can see, ubuntu comes with libjpeg, and if the only benefit of changing to the turbo version is speed of operations, that's not so important for my use case.
Then I keep reading about mozjpeg. Will mozjpeg get better optimisation results at the same image quality? I was reading #1422 (comment). I'm not sure I fully understand but does this mean that if you save a jpeg with these settings [optimize-coding,strip,interlace,optimize-scans,trellis-quant,quant_table=3] you get a similar result with libjpeg-turbo as mozjpeg? Or are these the recommended settings for using libvips with mozjpeg?
Again, if speed is not the issue and I want the smallest file size for the same quality of image, is mozjpeg the way to go? Or is it more complicated than that?
Thanks, Jonathan
Beta Was this translation helpful? Give feedback.
All reactions