Skip to content

Commit 5bee83a

Browse files
committed
add Vips\Main\cacheSetMax() etc
though it doesn't seem to autoload, strange
1 parent 497812b commit 5bee83a

File tree

4 files changed

+169
-6
lines changed

4 files changed

+169
-6
lines changed

src/Exception.php

+11
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@
5454
class Exception extends \Exception
5555
{
5656
}
57+
58+
/*
59+
* Local variables:
60+
* tab-width: 4
61+
* c-basic-offset: 4
62+
* End:
63+
* vim600: expandtab sw=4 ts=4 fdm=marker
64+
* vim<600: expandtab sw=4 ts=4
65+
*/
66+
67+
?>

src/Image.php

-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939

4040
namespace Jcupitt\Vips;
4141

42-
if (!extension_loaded("vips")) {
43-
if (!dl('vips.' . PHP_SHLIB_SUFFIX)) {
44-
echo "vips: unable to load vips extension\n";
45-
}
46-
}
47-
4842
/**
4943
* This class represents a Vips image object.
5044
*

src/Main.php

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
3+
/**
4+
* Vips is a php binding for the vips image processing library
5+
*
6+
* PHP version 7
7+
*
8+
* LICENSE:
9+
*
10+
* Copyright (c) 2016 John Cupitt
11+
*
12+
* Permission is hereby granted, free of charge, to any person obtaining
13+
* a copy of this software and associated documentation files (the
14+
* "Software"), to deal in the Software without restriction, including
15+
* without limitation the rights to use, copy, modify, merge, publish,
16+
* distribute, sublicense, and/or sell copies of the Software, and to
17+
* permit persons to whom the Software is furnished to do so, subject to
18+
* the following conditions:
19+
*
20+
* The above copyright notice and this permission notice shall be
21+
* included in all copies or substantial portions of the Software.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30+
*
31+
* @category Images
32+
* @package Jcupitt\Vips
33+
* @author John Cupitt <jcupitt@gmail.com>
34+
* @copyright 2016 John Cupitt
35+
* @license https://opensource.org/licenses/MIT MIT
36+
* @version GIT:ad44dfdd31056a41cbf217244ce62e7a702e0282
37+
* @link https://github.com/jcupitt/php-vips
38+
*/
39+
40+
namespace Jcupitt\Vips;
41+
42+
/**
43+
* This class contains the top-level libvips control methods.
44+
*
45+
* @category Images
46+
* @package Jcupitt\Vips
47+
* @author John Cupitt <jcupitt@gmail.com>
48+
* @copyright 2016 John Cupitt
49+
* @license https://opensource.org/licenses/MIT MIT
50+
* @version Release:0.1.2
51+
* @link https://github.com/jcupitt/php-vips
52+
*/
53+
class Main
54+
{
55+
/**
56+
* Set the maximum number of operations to hold in the libvips operation
57+
* cache.
58+
*
59+
* @param integer $value The maximum number of operations to cache.
60+
*
61+
* @return void
62+
*/
63+
public static function cacheSetMax($value)
64+
{
65+
vips_cache_set_max($value);
66+
}
67+
68+
/**
69+
* Set the maximum amount of memory to allow cached operations to use, in
70+
* bytes.
71+
*
72+
* @param integer $value The maximum amount of memory cached opertations can
73+
* hold, in bytes.
74+
*
75+
* @return void
76+
*/
77+
public static function cacheSetMaxMem($value)
78+
{
79+
vips_cache_set_max_mem($value);
80+
}
81+
82+
/**
83+
* Set the maximum number of open files cached operations can use.
84+
*
85+
* @param integer $value The maximum number of open files cached operations
86+
* can use.
87+
*
88+
* @return void
89+
*/
90+
public static function cacheSetMaxFiles($value)
91+
{
92+
vips_cache_set_max_files($value);
93+
}
94+
95+
/**
96+
* Set the size of the pools of worker threads vips uses for image
97+
* evaluation.
98+
*
99+
* @param integer $value The size of the pools of worker threads vips uses
100+
* for image evaluation.
101+
*
102+
* @return void
103+
*/
104+
public static function concurrencySet($value)
105+
{
106+
vips_concurrency_set($value);
107+
}
108+
109+
}
110+
111+
/*
112+
* Local variables:
113+
* tab-width: 4
114+
* c-basic-offset: 4
115+
* End:
116+
* vim600: expandtab sw=4 ts=4 fdm=marker
117+
* vim<600: expandtab sw=4 ts=4
118+
*/
119+
120+
?>

tests/Main.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use Jcupitt\Vips;
4+
5+
class VipsMainTest extends PHPUnit_Framework_TestCase
6+
{
7+
public function testVipsCacheSetMax()
8+
{
9+
/* Not easy to test ... just make sure it can execute.
10+
*/
11+
Vips\Main\cacheSetMax(12);
12+
}
13+
14+
public function testVipsCacheSetMaxMem()
15+
{
16+
Vips\Main\cacheSetMaxMem(12);
17+
}
18+
19+
public function testVipsCacheSetMaxFiles()
20+
{
21+
Vips\Main\cacheSetMaxFiles(12);
22+
}
23+
24+
public function testVipsConcurrencySet()
25+
{
26+
Vips\Main\concurrencySet(12);
27+
}
28+
29+
}
30+
31+
/*
32+
* Local variables:
33+
* tab-width: 4
34+
* c-basic-offset: 4
35+
* End:
36+
* vim600: expandtab sw=4 ts=4 fdm=marker
37+
* vim<600: expandtab sw=4 ts=4
38+
*/

0 commit comments

Comments
 (0)