libvips / php-vips

php binding for libvips
MIT License
615 stars 25 forks source link

AVIF file size is bigger than it's WebP equivalent #175

Closed sadektouati closed 1 year ago

sadektouati commented 1 year ago

Here's the code I use, require_once('vendor/autoload.php'); use Jcupitt\Vips; $image = Vips\Image::thumbnail(ORIGINAL_FILEPATH, $width, ['height' => 10000]); $image->writeToFile(FULL_FILEPATH); Why every single AVIF file has a bigger size than webp?

And also I noticed that Gmagick is a lot faster, which is ironic for me. What I'm doing wrongly?

jcupitt commented 1 year ago

Hi @sadektouati,

You'll need to share some more details so I can reproduce the problem. What versions of libwebp and which AVIF encoder are you using? What platform? How did you compile them? What type of image?

With libvips 8.13 on ubuntu 22.10 (libaom 3.4, libwebp 1.22) and this photo:

http://www.rollthepotato.net/~john/nina.jpg

I see:

$ time vips copy nina.jpg x.webp

real    0m1.516s
user    0m1.479s
sys 0m0.080s
$ time vips copy nina.jpg x.avif

real    0m4.298s
user    0m15.163s
sys 0m0.264s

And with imagemagick (my GM isn't set up for AVIF encode):

$ time convert nina.jpg x-im.webp

real    0m1.604s
user    0m1.483s
sys 0m0.120s

$ time convert nina.jpg x-im.avif

real    0m4.323s
user    0m16.249s
sys 0m0.332s

Then:

$ ls -l x* 
-rw-r--r-- 1 john john 182686 Nov 28 08:59 x.avif
-rw-rw-r-- 1 john john 164884 Nov 28 09:00 x-im.avif
-rw-rw-r-- 1 john john 434312 Nov 28 09:00 x-im.webp
-rw-r--r-- 1 john john 434330 Nov 28 08:59 x.webp

So speed is about the same, and AVIF is less than half the size with the default settings. Though of course 99% of CPU is being spent in the same libraries, so you'd expect them to be very similar.

sadektouati commented 1 year ago

Hi @jcupitt Here's my setting CentOS 8.5.2111 vips.x86_64 8.12.1-1.el8.remi libwebp.x86_64 1.0.0-5.el8 @appstream libaom.x86_64 3.1.1-1.el8 @epel

Hope this help.

jcupitt commented 1 year ago

Could you run those commands on that test image and post the results please.

sadektouati commented 1 year ago

@jcupitt I tried time vips copy nina.jpg x.avif It returns "killed"

sadektouati commented 1 year ago

@jcupitt I tried removing vips and reinstall it It gives this error: Problem: conflicting requests

jcupitt commented 1 year ago

Sorry, it sounds like something has gone wrong with your rpm install. I'd ask on the remi repository.