Skip to content

Commit 1f1b670

Browse files
committed
add magick example
1 parent fad7ada commit 1f1b670

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/vips-magick.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__ . '/../vendor/autoload.php';
5+
6+
use Jcupitt\Vips;
7+
8+
/* Load an image with libvips, render to a large memory buffer, wrap a imagick
9+
* image around that, then use imagick to save as another file.
10+
*/
11+
12+
$image = Vips\Image::newFromFile($argv[1],
13+
['access' => Vips\Access::SEQUENTIAL]);
14+
$image = $image->colourspace(Vips\Interpretation::RGB16);
15+
$bin = $image->writeToMemory();
16+
$imagick = new \Imagick();
17+
$imagick->setSize($image->width, $image->height);
18+
$imagick->setFormat("rgb");
19+
$imagick->readImageBlob($bin, "rgb");
20+
$imagick->writeImage($argv[2]);
21+
22+
/*
23+
* Local variables:
24+
* tab-width: 4
25+
* c-basic-offset: 4
26+
* End:
27+
* vim600: expandtab sw=4 ts=4 fdm=marker
28+
* vim<600: expandtab sw=4 ts=4
29+
*/

0 commit comments

Comments
 (0)