Skip to content

Commit d81a2a6

Browse files
committed
write_to_file was not setting options
the php options array was not being passed down to vips_image_write_to_file() see #3
1 parent a763afd commit d81a2a6

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
vips extension changelog
22

3+
Version 1.0.1 (2016-12-06)
4+
--------------------------
5+
* vips_image_write_to_file() was not setting options, see #3
6+
37
Version 1.0.0 (2016-11-24)
48
--------------------------
59
* Update package for pecl upload

vips.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44

55
/* Uncomment for some logging.
6-
#define VIPS_DEBUG
76
*/
7+
#define VIPS_DEBUG
88

99
#ifdef HAVE_CONFIG_H
1010
#include "config.h"
@@ -1243,6 +1243,11 @@ PHP_FUNCTION(vips_image_write_to_file)
12431243
size_t filename_len;
12441244
zval *options = NULL;
12451245
VipsImage *image;
1246+
char path_string[VIPS_PATH_MAX];
1247+
char option_string[VIPS_PATH_MAX];
1248+
const char *operation_name;
1249+
zval argv[2];
1250+
int argc;
12461251

12471252
VIPS_DEBUG_MSG("vips_image_write_to_file:\n");
12481253

@@ -1258,11 +1263,25 @@ PHP_FUNCTION(vips_image_write_to_file)
12581263

12591264
VIPS_DEBUG_MSG("\t%p -> %s\n", image, filename);
12601265

1261-
if (vips_image_write_to_file(image, filename, NULL)) {
1266+
vips__filename_split8(filename, path_string, option_string);
1267+
if (!(operation_name = vips_foreign_find_save(path_string))) {
12621268
RETURN_LONG(-1);
12631269
}
12641270

1265-
RETURN_LONG(0);
1271+
ZVAL_STRINGL(&argv[0], filename, filename_len);
1272+
argc = 1;
1273+
if (options) {
1274+
ZVAL_ARR(&argv[1], Z_ARR_P(options));
1275+
argc += 1;
1276+
}
1277+
1278+
if (vips_php_call_array(operation_name, IM,
1279+
option_string, argc, argv, return_value)) {
1280+
zval_dtor(&argv[0]);
1281+
RETURN_LONG(-1);
1282+
}
1283+
1284+
zval_dtor(&argv[0]);
12661285
}
12671286
/* }}} */
12681287

0 commit comments

Comments
 (0)