File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ All notable changes to `:vips` will be documented in this file.
44
55## master
66
7+ - add getFields() to fetch an array of field names
8+
79## 2.2.0 - 2023-08-17
810
911- improve FFI startup [ West14, jcupitt]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env php
2+ <?php
3+
4+ require dirname (__DIR__ ) . '/vendor/autoload.php ' ;
5+
6+ use Jcupitt \Vips ;
7+
8+ $ im = Vips \Image::newFromFile ($ argv [1 ]);
9+
10+ $ names = $ im ->getFields ();
11+
12+ echo "$ argv [1 ]\n" ;
13+ foreach ($ names as &$ name ) {
14+ $ value = $ im ->get ($ name );
15+ echo "$ name: $ value \n" ;
16+ }
17+
18+ /*
19+ * Local variables:
20+ * tab-width: 4
21+ * c-basic-offset: 4
22+ * End:
23+ * vim600: expandtab sw=4 ts=4 fdm=marker
24+ * vim<600: expandtab sw=4 ts=4
25+ */
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ private static function init(): void
348348 $ glib_decls = $ typedefs . <<<EOS
349349void* g_malloc (size_t size);
350350void g_free (void* data);
351+ void g_strfreev (char** str_array);
351352EOS ;
352353
353354 // GObject declarations
Original file line number Diff line number Diff line change 114114 * conform to PHP naming conventions, you can use something like
115115 * `$image->get('ipct-data')`.
116116 *
117+ * Use `$image->getFields()` to get an array of all the possible field names.
118+ *
117119 * Next we have:
118120 *
119121 * ```php
@@ -1217,6 +1219,25 @@ public function typeOf(string $name): int
12171219 return $ this ->getType ($ name );
12181220 }
12191221
1222+ /**
1223+ * Get the field names available for an image.
1224+ *
1225+ * @return Array
1226+ */
1227+ public function getFields (): array
1228+ {
1229+ $ str_array = FFI ::vips ()->vips_image_get_fields ($ this ->pointer );
1230+
1231+ $ fields = [];
1232+ for ($ i = 0 ; $ str_array [$ i ] != null ; $ i ++) {
1233+ array_push ($ fields , \FFI ::string ($ str_array [$ i ]));
1234+ }
1235+
1236+ FFI ::glib ()->g_free ($ str_array );
1237+
1238+ return $ fields ;
1239+ }
1240+
12201241 /**
12211242 * Set any property on the underlying image.
12221243 *
You can’t perform that action at this time.
0 commit comments