|
2 | 2 | <html lang="en-us"> |
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8"> |
5 | | - <title>Php-vips by jcupitt</title> |
| 5 | + <title>php-vips by jcupitt</title> |
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
7 | 7 | <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen"> |
8 | 8 | <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> |
|
11 | 11 | </head> |
12 | 12 | <body> |
13 | 13 | <section class="page-header"> |
14 | | - <h1 class="project-name">Php-vips</h1> |
| 14 | + <h1 class="project-name">php-vips</h1> |
15 | 15 | <h2 class="project-tagline">php binding for libvips</h2> |
16 | 16 | <a href="https://github.com/jcupitt/php-vips" class="btn">View on GitHub</a> |
17 | 17 | <a href="https://github.com/jcupitt/php-vips/zipball/master" class="btn">Download .zip</a> |
18 | 18 | <a href="https://github.com/jcupitt/php-vips/tarball/master" class="btn">Download .tar.gz</a> |
19 | 19 | </section> |
20 | 20 |
|
21 | 21 | <section class="main-content"> |
22 | | - <h3> |
23 | | -<a id="welcome-to-github-pages" class="anchor" href="#welcome-to-github-pages" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Welcome to GitHub Pages.</h3> |
| 22 | + <h1> |
| 23 | +<a id="high-level-php-binding-for-libvips" class="anchor" href="#high-level-php-binding-for-libvips" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>High-level PHP binding for libvips</h1> |
24 | 24 |
|
25 | | -<p>This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here <a href="https://guides.github.com/features/mastering-markdown/">using GitHub Flavored Markdown</a>, select a template crafted by a designer, and publish. After your page is generated, you can check out the new <code>gh-pages</code> branch locally. If you’re using GitHub Desktop, simply sync your repository and you’ll see the new branch.</p> |
| 25 | +<p><code>php-vips</code> is a binding for <a href="https://github.com/jcupitt/libvips">libvips</a> for |
| 26 | +PHP 7. We have a set of <a href="docs/index.html">formatted API docs</a>. </p> |
| 27 | + |
| 28 | +<p>libvips is fast and needs little memory. The <a href="https://github.com/jcupitt/php-vips-bench"><code>vips-php-bench</code></a> repository tests |
| 29 | +<code>php-vips</code> against <code>imagick</code> and <code>gd</code>. On that test, and on my laptop, |
| 30 | +<code>php-vips</code> is around four times faster than <code>imagick</code> and needs 10 times less |
| 31 | +memory. </p> |
| 32 | + |
| 33 | +<p>Programs that use libvips don't manipulate images directly, instead they |
| 34 | +create pipelines of image processing operations starting from a source |
| 35 | +image. When the pipe is connected to a destination, the whole pipeline |
| 36 | +executes at once and in parallel, streaming the image from source to |
| 37 | +destination in a set of small fragments.</p> |
| 38 | + |
| 39 | +<p>This module builds upon the <code>vips</code> PHP extension, see:</p> |
| 40 | + |
| 41 | +<p><a href="https://github.com/jcupitt/php-vips-ext">https://github.com/jcupitt/php-vips-ext</a></p> |
| 42 | + |
| 43 | +<p>You'll need to install that first. It's tested on Linux and macOS --- |
| 44 | +Windows would need some work, but should be possible. </p> |
| 45 | + |
| 46 | +<h3> |
| 47 | +<a id="example" class="anchor" href="#example" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Example</h3> |
| 48 | + |
| 49 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c">#!/usr/bin/env php</span></span> |
| 50 | +<span class="pl-s1"><span class="pl-k"><</span>?<span class="pl-c1">php</span></span> |
| 51 | +<span class="pl-s1"><span class="pl-k">require</span> <span class="pl-c1">__DIR__</span> <span class="pl-k">.</span> <span class="pl-s"><span class="pl-pds">'</span>/vendor/autoload.php<span class="pl-pds">'</span></span>;</span> |
| 52 | +<span class="pl-s1"><span class="pl-k">use</span> <span class="pl-c1">Jcupitt\Vips</span>;</span> |
| 53 | +<span class="pl-s1"></span> |
| 54 | +<span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-c1">Vips\</span><span class="pl-c1">Image</span><span class="pl-k">::</span>newFromFile(<span class="pl-smi">$argv</span>[<span class="pl-c1">1</span>]);</span> |
| 55 | +<span class="pl-s1"></span> |
| 56 | +<span class="pl-s1"><span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>width = <span class="pl-pds">"</span></span>, <span class="pl-smi">$image</span><span class="pl-k">-></span><span class="pl-smi">width</span>, <span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\n</span><span class="pl-pds">"</span></span>;</span> |
| 57 | +<span class="pl-s1"></span> |
| 58 | +<span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>invert();</span> |
| 59 | +<span class="pl-s1"></span> |
| 60 | +<span class="pl-s1"><span class="pl-smi">$image</span><span class="pl-k">-></span>writeToFile(<span class="pl-smi">$argv</span>[<span class="pl-c1">2</span>]);</span> |
| 61 | +<span class="pl-s1"></span><span class="pl-pse"><span class="pl-s1">?</span>></span></pre></div> |
| 62 | + |
| 63 | +<p>You'll need this in your <code>composer.json</code>:</p> |
| 64 | + |
| 65 | +<pre><code> "require": { |
| 66 | + "jcupitt/vips" : "1.0.0" |
| 67 | + } |
| 68 | +</code></pre> |
| 69 | + |
| 70 | +<p>And run with:</p> |
| 71 | + |
| 72 | +<pre><code>$ composer install |
| 73 | +$ ./try1.php ~/pics/k2.jpg x.tif |
| 74 | +</code></pre> |
| 75 | + |
| 76 | +<p>See <code>examples/</code>.</p> |
26 | 77 |
|
27 | 78 | <h3> |
28 | | -<a id="designer-templates" class="anchor" href="#designer-templates" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Designer Templates</h3> |
| 79 | +<a id="introduction-to-the-api" class="anchor" href="#introduction-to-the-api" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Introduction to the API</h3> |
| 80 | + |
| 81 | +<p>Almost all methods return a new image for the result, so you can chain them. |
| 82 | +For example:</p> |
| 83 | + |
| 84 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>more(<span class="pl-c1">12</span>)<span class="pl-k">-></span>ifthenelse(<span class="pl-c1">255</span>, <span class="pl-smi">$image</span>);</span></pre></div> |
| 85 | + |
| 86 | +<p>will make a mask of pixels greater than 12, then use the mask to set pixels to |
| 87 | +either 255 or the original image.</p> |
29 | 88 |
|
30 | | -<p>We’ve crafted some handsome templates for you to use. Go ahead and click 'Continue to layouts' to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved.</p> |
| 89 | +<p>You use long, double, array and image as parameters. For example:</p> |
| 90 | + |
| 91 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>add(<span class="pl-c1">2</span>);</span></pre></div> |
| 92 | + |
| 93 | +<p>to add two to every band element, or:</p> |
| 94 | + |
| 95 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>add([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>]);</span></pre></div> |
| 96 | + |
| 97 | +<p>to add 1 to the first band, 2 to the second and 3 to the third. Or:</p> |
| 98 | + |
| 99 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>add(<span class="pl-smi">$image2</span>);</span></pre></div> |
| 100 | + |
| 101 | +<p>to add two images. Or: </p> |
| 102 | + |
| 103 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span> <span class="pl-k">=</span> <span class="pl-smi">$image</span><span class="pl-k">-></span>add([[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>], [<span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>]]);</span></pre></div> |
| 104 | + |
| 105 | +<p>To make a 2 x 3 image from the array, then add that image to the original.</p> |
| 106 | + |
| 107 | +<p>Almost all methods can take an extra final argument: an array of options. |
| 108 | +For example:</p> |
| 109 | + |
| 110 | +<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-smi">$image</span><span class="pl-k">-></span>writeToFile(<span class="pl-s"><span class="pl-pds">"</span>fred.jpg<span class="pl-pds">"</span></span>, [<span class="pl-s"><span class="pl-pds">"</span>Q<span class="pl-pds">"</span></span> <span class="pl-k">=></span> <span class="pl-c1">90</span>]);</span></pre></div> |
| 111 | + |
| 112 | +<p><code>php-vips</code> comes with full API docs, run:</p> |
| 113 | + |
| 114 | +<pre><code>$ vendor/bin/phpdoc |
| 115 | +</code></pre> |
| 116 | + |
| 117 | +<p>And look in <code>docs/</code>.</p> |
| 118 | + |
| 119 | +<p>There are around 300 operations in the library, see the vips docs for an |
| 120 | +introduction:</p> |
| 121 | + |
| 122 | +<p><a href="http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/">http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/</a></p> |
31 | 123 |
|
32 | 124 | <h3> |
33 | | -<a id="creating-pages-manually" class="anchor" href="#creating-pages-manually" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Creating pages manually</h3> |
| 125 | +<a id="how-it-works" class="anchor" href="#how-it-works" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>How it works</h3> |
| 126 | + |
| 127 | +<p>The <code>vips</code> extension defines a simple but ugly way to call any libvips |
| 128 | +operation from PHP. It uses libvips' own introspection facilities |
| 129 | +and does not depend on anything else (so no gobject-introspection, |
| 130 | +for example). It's a fairly short 1,600 lines of C.</p> |
34 | 131 |
|
35 | | -<p>If you prefer to not use the automatic generator, push a branch named <code>gh-pages</code> to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.</p> |
| 132 | +<p>This module is a PHP layer over the ugly <code>vips</code> extension that |
| 133 | +tries to make a nice interface for programmers. It uses <code>__call()</code> and |
| 134 | +<code>__get()</code> to make all libvips operations appear as methods, and all |
| 135 | +libvips properties as properties of the PHP <code>Vips\Image</code> class.</p> |
36 | 136 |
|
37 | 137 | <h3> |
38 | | -<a id="authors-and-contributors" class="anchor" href="#authors-and-contributors" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Authors and Contributors</h3> |
| 138 | +<a id="test-and-install" class="anchor" href="#test-and-install" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Test and install</h3> |
39 | 139 |
|
40 | | -<p>You can @mention a GitHub username to generate a link to their profile. The resulting <code><a></code> element will link to the contributor’s GitHub Profile. For example: In 2007, Chris Wanstrath (<a href="https://github.com/defunkt" class="user-mention">@defunkt</a>), PJ Hyett (<a href="https://github.com/pjhyett" class="user-mention">@pjhyett</a>), and Tom Preston-Werner (<a href="https://github.com/mojombo" class="user-mention">@mojombo</a>) founded GitHub.</p> |
| 140 | +<pre><code>$ phpcs --standard=PSR2 src |
| 141 | +$ php ~/packages/php/composer.phar install |
| 142 | +$ vendor/bin/phpunit |
| 143 | +$ vendor/bin/phpdoc |
| 144 | +</code></pre> |
41 | 145 |
|
42 | 146 | <h3> |
43 | | -<a id="support-or-contact" class="anchor" href="#support-or-contact" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Support or Contact</h3> |
| 147 | +<a id="regenerate-auto-docs" class="anchor" href="#regenerate-auto-docs" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Regenerate auto docs</h3> |
44 | 148 |
|
45 | | -<p>Having trouble with Pages? Check out our <a href="https://help.github.com/pages">documentation</a> or <a href="https://github.com/contact">contact support</a> and we’ll help you sort it out.</p> |
| 149 | +<pre><code>$ cd src |
| 150 | +$ ../examples/generate_phpdoc.rb |
| 151 | +</code></pre> |
46 | 152 |
|
47 | 153 | <footer class="site-footer"> |
48 | | - <span class="site-footer-owner"><a href="https://github.com/jcupitt/php-vips">Php-vips</a> is maintained by <a href="https://github.com/jcupitt">jcupitt</a>.</span> |
| 154 | + <span class="site-footer-owner"><a href="https://github.com/jcupitt/php-vips">php-vips</a> is maintained by <a href="https://github.com/jcupitt">jcupitt</a>.</span> |
49 | 155 |
|
50 | 156 | <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span> |
51 | 157 | </footer> |
|
0 commit comments