Skip to content

Commit 461706f

Browse files
committedMar 11, 2017
add image type sniffers
add vips_foreign_find_load() and vips_foreign_find_load_buffer(), plus tests bump version to 1.0.5
1 parent c493fcb commit 461706f

File tree

8 files changed

+106
-7
lines changed

8 files changed

+106
-7
lines changed
 

‎ChangeLog

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
vips extension changelog
22

3-
dev
4-
---
3+
Version 1.0.5 (2017-3-11)
4+
--------------------------
55
* Use VIPS_SONAME, if we can
66
* More stuff in php_info(), see https://github.com/jcupitt/php-vips/issues/32
7+
* Add vips_foreign_find_load() and vips_foreign_find_load_buffer(), see https://github.com/jcupitt/php-vips/issues/37
78

89
Version 1.0.4 (2016-12-30)
910
--------------------------
File renamed without changes.

‎package.xml

+17-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
1515
<email>jcupitt@php.net</email>
1616
<active>yes</active>
1717
</lead>
18-
<date>2016-12-30</date>
18+
<date>2017-03-11</date>
1919
<version>
20-
<release>1.0.4</release>
20+
<release>1.0.5</release>
2121
<api>1.0.0</api>
2222
</version>
2323
<stability>
@@ -26,16 +26,17 @@ http://pear.php.net/dtd/package-2.0.xsd">
2626
</stability>
2727
<license filesource="LICENSE.txt">MIT</license>
2828
<notes>
29-
* Improve graceful fix from 1.0.3, see https://github.com/jcupitt/php-vips/issues/27
30-
* Better notes section in package.xml, see https://github.com/jcupitt/php-vips/issues/28
29+
* Use VIPS_SONAME, if we can
30+
* More stuff in php_info(), see https://github.com/jcupitt/php-vips/issues/32
31+
* Add vips_foreign_find_load() and vips_foreign_find_load_buffer(), see https://github.com/jcupitt/php-vips/issues/37
3132
</notes>
3233
<contents>
3334
<dir name="/">
3435
<file role='doc' name='API-1.0.0'/>
3536
<file role='doc' name='CREDITS'/>
3637
<file role='doc' name='LICENSE.txt'/>
3738
<file role='doc' name='README.md'/>
38-
<file role='doc' name='RELEASE-1.0.4'/>
39+
<file role='doc' name='RELEASE-1.0.5'/>
3940
<file role='doc' name='ChangeLog'/>
4041

4142
<file role='src' name='config.m4'/>
@@ -90,6 +91,17 @@ http://pear.php.net/dtd/package-2.0.xsd">
9091
</extsrcrelease>
9192
<changelog>
9293

94+
<release>
95+
<stability><release>stable</release><api>stable</api></stability>
96+
<version><release>1.0.5</release><api>1.0.0</api></version>
97+
<date>2017-03-11</date>
98+
<notes>
99+
* Use VIPS_SONAME, if we can
100+
* More stuff in php_info(), see https://github.com/jcupitt/php-vips/issues/32
101+
* Add vips_foreign_find_load() and vips_foreign_find_load_buffer(), see https://github.com/jcupitt/php-vips/issues/37
102+
</notes>
103+
</release>
104+
93105
<release>
94106
<stability><release>stable</release><api>stable</api></stability>
95107
<version><release>1.0.4</release><api>1.0.0</api></version>

‎tests/032.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
foreign_find_load_buffer works
3+
--SKIPIF--
4+
<?php if (!extension_loaded("vips")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$filename = dirname(__FILE__) . "/images/img_0076.jpg";
8+
$buffer = file_get_contents($filename);
9+
10+
$loader = vips_foreign_find_load_buffer($buffer);
11+
12+
if ($loader == "VipsForeignLoadJpegBuffer") {
13+
echo "pass";
14+
}
15+
?>
16+
--EXPECT--
17+
pass

‎tests/033.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
foreign_find_load works
3+
--SKIPIF--
4+
<?php if (!extension_loaded("vips")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$filename = dirname(__FILE__) . "/images/img_0076.jpg";
8+
9+
$loader = vips_foreign_find_load($filename);
10+
11+
if ($loader == "VipsForeignLoadJpegFile") {
12+
echo "pass";
13+
}
14+
?>
15+
--EXPECT--
16+
pass

‎vips-1.0.4.tgz

150 Bytes
Binary file not shown.

‎vips-1.0.5.tgz

543 KB
Binary file not shown.

‎vips.c

+53
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,48 @@ PHP_FUNCTION(vips_image_write_to_buffer)
13311331
}
13321332
/* }}} */
13331333

1334+
/* {{{ proto string|long vips_foreign_find_load(string filename)
1335+
Find a loader for a file */
1336+
PHP_FUNCTION(vips_foreign_find_load)
1337+
{
1338+
char *filename;
1339+
size_t filename_len;
1340+
const char *operation_name;
1341+
1342+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
1343+
&filename, &filename_len) == FAILURE) {
1344+
RETURN_LONG(-1);
1345+
}
1346+
1347+
if (!(operation_name = vips_foreign_find_load(filename))) {
1348+
RETURN_LONG(-1);
1349+
}
1350+
1351+
RETVAL_STRING(strdup(operation_name));
1352+
}
1353+
/* }}} */
1354+
1355+
/* {{{ proto string|long vips_foreign_find_load_buffer(string buffer)
1356+
Find a loader for a buffer */
1357+
PHP_FUNCTION(vips_foreign_find_load_buffer)
1358+
{
1359+
char *buffer;
1360+
size_t buffer_len;
1361+
const char *operation_name;
1362+
1363+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
1364+
&buffer, &buffer_len) == FAILURE) {
1365+
RETURN_LONG(-1);
1366+
}
1367+
1368+
if (!(operation_name = vips_foreign_find_load_buffer(buffer, buffer_len))) {
1369+
RETURN_LONG(-1);
1370+
}
1371+
1372+
RETVAL_STRING(strdup(operation_name));
1373+
}
1374+
/* }}} */
1375+
13341376
/* {{{ proto array vips_image_get(resource image, string field)
13351377
Fetch field from image */
13361378
PHP_FUNCTION(vips_image_get)
@@ -1811,6 +1853,14 @@ ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_buffer, 0)
18111853
ZEND_ARG_INFO(0, options)
18121854
ZEND_END_ARG_INFO()
18131855

1856+
ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load, 0)
1857+
ZEND_ARG_INFO(0, filename)
1858+
ZEND_END_ARG_INFO()
1859+
1860+
ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load_buffer, 0)
1861+
ZEND_ARG_INFO(0, buffer)
1862+
ZEND_END_ARG_INFO()
1863+
18141864
ZEND_BEGIN_ARG_INFO(arginfo_vips_call, 0)
18151865
ZEND_ARG_INFO(0, operation_name)
18161866
ZEND_ARG_INFO(0, instance)
@@ -1866,6 +1916,9 @@ const zend_function_entry vips_functions[] = {
18661916
PHP_FE(vips_image_new_from_array, arginfo_vips_image_new_from_array)
18671917
PHP_FE(vips_image_write_to_file, arginfo_vips_image_write_to_file)
18681918
PHP_FE(vips_image_write_to_buffer, arginfo_vips_image_write_to_buffer)
1919+
PHP_FE(vips_foreign_find_load, arginfo_vips_foreign_find_load)
1920+
PHP_FE(vips_foreign_find_load_buffer, arginfo_vips_foreign_find_load_buffer)
1921+
18691922
PHP_FE(vips_call, arginfo_vips_call)
18701923
PHP_FE(vips_image_get, arginfo_vips_image_get)
18711924
PHP_FE(vips_image_get_typeof, arginfo_vips_image_get_typeof)

0 commit comments

Comments
 (0)