I am attempting to use the libvips package on Windows 11.
I have installed the composer package "jcupitt/vips": "2.0.0"
My local PHP setup is laragon, and I have enabled the FFI extension for PHP.
I have installed libvips binary for Windows and added it to the path. It works when I call it from the command line directly. Example: vips invert input.png output.png
When running the following file (which uses FFI):
<?php
require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
use Jcupitt\Vips;
// fast thumbnail generator
$image = Vips\Image::thumbnail('example-rug.jpg', 128);
$image->writeToFile('tiny.jpg');
Fatal error: Uncaught FFI\Exception: Failed resolving C function 'g_malloc' in C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php:773 Stack trace: #0 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php(773): FFI::cdef('// we need the ...', 'libvips-42.dll') #1 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php(195): Jcupitt\Vips\Config::init() #2 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php(259): Jcupitt\Vips\Config::ffi() #3 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Image.php(712): Jcupitt\Vips\Config::filenameGetFilename('..\example-rug....') #4 C:\laragon\www\efc\rugz\src\examples\bench.php(8): Jcupitt\Vips\Image::newFromFile('..\example-rug....', Array) #5 {main}
Next FFI\Exception: Failed resolving C function 'g_free' in C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php:773 Stack trace: #0 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php(773): FFI::cdef('// we need the ...', 'libvips-42.dll') #1 C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php in C:\laragon\www\efc\rugz\vendor\jcupitt\vips\src\Config.php on line 773
All I could think is that these are 2 glib functions and maybe I do not have the glib dll file?
I checked the vips bin folder, and libglib-2.0-0.dll
is found there. This is in the same bin folder, so it should be found at the path if necessary.
I know this is being pulled in via the libvips-42.dll
, because if I rename libglib-2.0-0.dll
file, the FFI output becomes:
Fatal error: Uncaught FFI\Exception: Failed loading 'libvips-42.dll'
The last bit of info I can provide is that the offending portion of the command fed to FFI appears to be:
void* g_malloc (size_t size);
void g_free (void* data);