You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libvips has a special thumbnail operation which can load and resize an image in one step. Because the two things happen together, it can exploit a lot of tricks with the various load libraries, often giving a large speedup.
For example, here's roughly what intervention-image-vips-driver does now:
44mb and 0.06s -- half the memory use and almost 3x faster. In fact it's faster still, since in both cases you're paying the same fixed startup cost for libvips:
$ /usr/bin/time -f %M:%e vips
...
31232:0.02
So the real difference is 0.15s vs 0.04, almost 4x faster.
Moreover, thumbnail knows about things like alpha and will premultiply if necessary, so you get better quality too.
I realise load+save in one operation does not fit so well with the architecture you have to work with and might need some thought :(
You could make this faster by putting the alpha into the brightness array. Something like:
// what about mono or cmyk images? is intervention always rgb? it might be better// to use $core->bands to get the number of image bands rather than assuming three$brighten = [$level, $level, $level];
if ($core->hasAlpha()) {
$brighten[] = 1;
}
$core = $core->add($brighten);
Now there's no need to add and remove the alpha.
The text was updated successfully, but these errors were encountered:
Hello, I just found this very nice project.
libvips has a special
thumbnail
operation which can load and resize an image in one step. Because the two things happen together, it can exploit a lot of tricks with the various load libraries, often giving a large speedup.For example, here's roughly what
intervention-image-vips-driver
does now:104mb and 0.17s to size down to 302 pixels across. If you use
thumbnail
instead:44mb and 0.06s -- half the memory use and almost 3x faster. In fact it's faster still, since in both cases you're paying the same fixed startup cost for libvips:
So the real difference is 0.15s vs 0.04, almost 4x faster.
Moreover,
thumbnail
knows about things like alpha and will premultiply if necessary, so you get better quality too.I realise load+save in one operation does not fit so well with the architecture you have to work with and might need some thought :(
I noticed some other small things, for example:
https://github.com/osiemsiedem/intervention-image-vips-driver/blob/master/src/Commands/BrightnessCommand.php#L25-L33
You could make this faster by putting the alpha into the brightness array. Something like:
Now there's no need to add and remove the alpha.
The text was updated successfully, but these errors were encountered: