PHPackages                             jcupitt/vips - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. jcupitt/vips

ActiveLibrary[Image &amp; Media](/categories/media)

jcupitt/vips
============

A high-level interface to the libvips image processing library.

v2.6.1(6mo ago)7091.8M↓23.1%32[10 issues](https://github.com/libvips/php-vips/issues)[1 PRs](https://github.com/libvips/php-vips/pulls)20MITPHPPHP &gt;=7.4CI failing

Since Oct 19Pushed 2mo ago19 watchersCompare

[ Source](https://github.com/libvips/php-vips)[ Packagist](https://packagist.org/packages/jcupitt/vips)[ Docs](https://github.com/libvips/php-vips)[ RSS](/packages/jcupitt-vips/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (37)Used By (20)

PHP binding for libvips
=======================

[](#php-binding-for-libvips)

[![CI](https://github.com/libvips/php-vips/workflows/CI/badge.svg)](https://github.com/libvips/php-vips/actions)

`php-vips` is a binding for [libvips](https://github.com/libvips/libvips) 8.7 and later that runs on PHP 7.4 and later.

libvips is fast and needs little memory. The [`vips-php-bench`](https://github.com/jcupitt/php-vips-bench) repository tests `php-vips` against `imagick` and `gd`. On that test, and on my laptop, `php-vips` is around four times faster than `imagick` and needs 10 times less memory.

Programs that use libvips don't manipulate images directly, instead they create pipelines of image processing operations starting from a source image. When the pipe is connected to a destination, the whole pipeline executes at once and in parallel, streaming the image from source to destination in a set of small fragments.

### Install

[](#install)

You need to [install the libvips library](https://www.libvips.org/install.html). It's in the linux package managers, homebrew and MacPorts, and there are Windows binaries on the vips website. For example, on Debian:

```
sudo apt-get install --no-install-recommends libvips42

```

(`--no-install-recommends` stops Debian installing a *lot* of extra packages)

Or macOS:

```
brew install vips

```

You'll need to [enable FFI in your PHP](https://www.php.net/manual/en/ffi.configuration.php), then add vips to your `composer.json`:

```
"require": {
    "jcupitt/vips" : "2.4.0"
}

```

php-vips does not yet support preloading, so you need to enable FFI globally. This has some security implications, since anyone who can run php on your server can use it to call any native library they have access to.

Of course if attackers are running their own PHP code on your webserver you are probably already toast, unfortunately.

Finally, on php 8.3 and later you need to disable stack overflow tests. php-vips executes FFI callbacks off the main thread and this confuses those checks, at least in php 8.3.0.

Add:

```
zend.max_allowed_stack_size=-1

```

To your `php.ini`.

### Example

[](#example)

```
#!/usr/bin/env php
