Skip to content

Commit e3cb1da

Browse files
committed
revise README
1 parent 4b5dcc0 commit e3cb1da

File tree

2 files changed

+35
-63
lines changed

2 files changed

+35
-63
lines changed

README.md

+35-63
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,85 @@
11
# Low-level PHP binding for libvips
22

3-
This extension lets you use the libvips image processing library from PHP. It is
4-
intentionally very low-level. Modules such as
5-
https://github.com/jcupitt/php-vips try to layer a nice API on
6-
top of this.
7-
8-
libvips is fast and it can work without needing to have the
9-
entire image loaded into memory. Programs that use libvips don't
10-
manipulate images directly, instead they create pipelines of image processing
11-
operations starting from a source image. When the end of the pipe is connected
12-
to a destination, the whole pipeline executes at once, streaming the image
13-
in parallel from source to destination in a set of small fragments.
14-
15-
See the [benchmarks at the official libvips
16-
website](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use).
17-
There's a handy blog post explaining [how libvips opens
18-
files](http://libvips.blogspot.co.uk/2012/06/how-libvips-opens-file.html)
19-
which gives some more background.
3+
This extension lets you use the libvips image processing library from PHP 7. It
4+
is intentionally very low-level: modules such as
5+
https://github.com/jcupitt/php-vips try to layer a nice API on top of this.
6+
7+
libvips is fast and needs little memory. The [`vips-php-bench`](
8+
https://github.com/jcupitt/php-vips-bench) repository tests
9+
`php-vips` against `imagick` and `gd`: on that test, and on my laptop,
10+
`php-vips` is around four times faster than `imagick` and needs 10 times less
11+
memory.
2012

2113
### Example
2214

2315
```php
2416
#!/usr/bin/env php
2517
<?php
26-
if (!extension_loaded("vips")) {
27-
dl('vips.' . PHP_SHLIB_SUFFIX);
28-
}
2918

3019
$x = vips_image_new_from_file($argv[1])["out"];
3120
$x = vips_call("invert", $x)["out"];
3221
vips_image_write_to_file($x, $argv[2]);
33-
?>
3422
```
3523

3624
Almost all operations return an array of result values. Usually there is a
3725
single result called `"out"`.
3826

3927
Use `vips_call()` to call any operation in the vips library. There are around
40-
around 300 operations available, see the vips docs for an
41-
introduction:
28+
around 300 operations available, see the vips docs for an introduction:
4229

4330
http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/
4431

4532
Arguments can be long, double, image, array of long, array of double or array
4633
of image. The final argument to `vips_call()` is an array of operation options.
4734

48-
### Preparation
35+
`php-vips` layers a nice API, including full docs, on top of this extension,
36+
see:
4937

50-
PHP is normally built for speed and is missing a lot of debugging support you
51-
need for extension development. For testing and dev, build your own php.
52-
I used 7.0.11 and configured with:
38+
https://github.com/jcupitt/php-vips
5339

54-
```
55-
$ ./configure --prefix=/home/john/vips --enable-debug --enable-maintainer-zts \
56-
--enable-cgi --enable-cli --with-readline --with-openssl --with-zlib \
57-
--with-gd --with-jpeg-dir=/usr --with-libxml-dir=/usr
58-
```
40+
### Installing
5941

60-
You'll need libvips 8.0 or later, including all the headers for
61-
development. On linux, install with your package manager. On OS X,
62-
install with `brew` or MacPorts. For Windows, download a zip from the
63-
libvips website, or build your own.
42+
On OS X, use `brew install php70-vips` to install the libvips library, php and
43+
this php extension.
6444

65-
### Installing
45+
On Linux, install this extension with:
6646

6747
```
68-
$ pear install vips-0.1.2.tgz
48+
$ pear install vips-0.1.3.tgz
6949
```
7050

71-
to install.
72-
73-
Add:
51+
And add:
7452

7553
```
7654
extension=vips.so
7755
```
7856

79-
to your `php.ini`, perhaps in `~/vips/lib/php.ini`, if you configured php as
80-
above.
81-
82-
### Using
57+
to your `php.ini`.
8358

84-
Try:
59+
### Development: preparation
8560

86-
```php
87-
#!/usr/bin/env php
88-
<?php
89-
if (!extension_loaded("vips")) {
90-
dl('vips.' . PHP_SHLIB_SUFFIX);
91-
}
92-
93-
$x = vips_image_new_from_file($argv[1])["out"];
94-
$x = vips_call("invert", $x)["out"];
95-
vips_image_write_to_file($x, $argv[2]);
96-
?>
97-
```
98-
99-
And run with:
61+
PHP is normally built for speed and is missing a lot of debugging support you
62+
need for extension development. For testing and dev, build your own php.
63+
I used 7.0.11 and configured with:
10064

10165
```
102-
$ ./try1.php ~/pics/k2.jpg x.tif
66+
$ ./configure --prefix=/home/john/vips --enable-debug --enable-maintainer-zts \
67+
--enable-cgi --enable-cli --with-readline --with-openssl --with-zlib \
68+
--with-gd --with-jpeg-dir=/usr --with-libxml-dir=/usr
10369
```
10470

105-
See `examples/`.
71+
You'll need libvips 8.0 or later, including all the headers for
72+
development. On linux, install with your package manager. On OS X,
73+
install with `brew` or MacPorts. For Windows, download a zip from the
74+
libvips website, or build your own.
10675

10776
### Development: regenerate build system
10877

10978
```
11079
$ pear package
11180
```
11281

113-
to make `vips-0.1.2.tgz`.
82+
to make `vips-0.1.3.tgz`.
11483

11584
To install by hand:
11685

@@ -159,6 +128,9 @@ Finally, install to your php extensions area with:
159128
$ make install
160129
```
161130

131+
Add `extension-vips.so` to `php.ini`, perhaps in `~/vips/lib/php.ini`,
132+
if you configured php as above.
133+
162134
### Links
163135

164136
http://php.net/manual/en/internals2.php

vips-0.1.3.tgz

-227 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)