File tree Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ Version 0.1.1 (2016-10-03)
5
5
* Support draw operations
6
6
* Add vips_error_buffer(), remove docref messages
7
7
* Return 0/-1 everywhere for error
8
- * Vips_image_get() returns ["out" => value] | -1
8
+ * vips_image_get() returns ["out" => value] | -1
9
+ * vips_image_get() returns built-in enums as strings
9
10
* Fix type conversions
10
11
* Add vips_image_remove()
11
12
* Add vips_cache_set_*()
Original file line number Diff line number Diff line change @@ -13,9 +13,3 @@ vips can get image header fields
13
13
?>
14
14
--EXPECT--
15
15
pass
16
- --CLEAN--
17
- <?php
18
- $ output_filename = dirname (__FILE__ ) . "/x.tif " ;
19
- unlink ($ output_filename );
20
- ?>
21
-
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ enum fields are returned as strings
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ("vips " )) print "skip " ; ?>
5
+ --FILE--
6
+ <?php
7
+ $ filename = dirname (__FILE__ ) . "/images/img_0076.jpg " ;
8
+ $ image = vips_image_new_from_file ($ filename )["out " ];
9
+ $ interpretation = vips_image_get ($ image , "interpretation " )["out " ];
10
+ if ($ interpretation == "srgb " ) {
11
+ echo ("pass \n" );
12
+ }
13
+ ?>
14
+ --EXPECT--
15
+ pass
Original file line number Diff line number Diff line change @@ -1254,6 +1254,7 @@ PHP_FUNCTION(vips_image_get)
1254
1254
VipsImage * image ;
1255
1255
GValue gvalue = { 0 };
1256
1256
zval zvalue ;
1257
+ GParamSpec * pspec ;
1257
1258
1258
1259
if (zend_parse_parameters (ZEND_NUM_ARGS (), "rs" ,
1259
1260
& im , & field_name , & field_name_len ) == FAILURE ) {
@@ -1265,7 +1266,20 @@ PHP_FUNCTION(vips_image_get)
1265
1266
RETURN_LONG (-1 );
1266
1267
}
1267
1268
1268
- if (vips_image_get (image , field_name , & gvalue )) {
1269
+ /* Ugly: older libvipses would return enums from the true header fields
1270
+ * (eg. ->interpretation) as ints, but we want to send a string back
1271
+ * for things like this.
1272
+ *
1273
+ * Test if field_name exists as a regular glib property and if it does, use
1274
+ * g_object_get(). Otherwise use vips_image_get(), since it can read extra
1275
+ * image metadata.
1276
+ */
1277
+ if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (image ),
1278
+ field_name ))) {
1279
+ g_value_init (& gvalue , G_PARAM_SPEC_VALUE_TYPE (pspec ));
1280
+ g_object_get_property (G_OBJECT (image ), field_name , & gvalue );
1281
+ }
1282
+ else if (vips_image_get (image , field_name , & gvalue )) {
1269
1283
RETURN_LONG (-1 );
1270
1284
}
1271
1285
You can’t perform that action at this time.
0 commit comments