php-vips is rather like imagick, but, at least on this benchmark, 4x faster and needs 10x less memory.
To install, see the README, but briefly:
- Install the development version of the underlying libvips library. It's in
the linux package managers, homebrew and MacPorts, and there are Windows
binaries on the vips website. For example, on Debian:
Or macOS:sudo apt-get install libvips-dev
brew install vips
- Install the binary PHP extension:
You may need to addpecl install vips
extension=vips.so
or equivalent tophp.ini
, see the output of pecl. - Add vips to your
composer.json
:
"require": { "jcupitt/vips" : "1.0.0" }
Run with:#!/usr/bin/env php <?php require __DIR__ . '/vendor/autoload.php'; use Jcupitt\Vips; $image = Vips\Image::newFromFile($argv[1]); echo "width = ", $image->width, "\n"; $image = $image->invert(); $image->writeToFile($argv[2]);
To load an image, invert it, and save again.$ composer install $ ./try1.php ~/pics/k2.jpg x.tif
We have the full formatted docs on line as well, including a tutorial and some background on how the thing works. The examples/ directory has some more sample code.
No comments:
Post a Comment