Skip to content

Commit

Permalink
add image quality setting
Browse files Browse the repository at this point in the history
  • Loading branch information
shenzhe committed Jun 5, 2014
1 parent 48831a9 commit cdd1113
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ zhtmltopdf, 把html页面转成pdf或image的php扩展
echo $content;

//参数1: 网址
//参数2: 输出的img文件名
//会生成图片文件
//参数2: 生成的img文件名 (可选)
//参数3: 图片fmt(可选) jpeg(默认), png, bmp
//参数4: 图片质量(可选) 默认80
zhtml2img("http://www.baidu.com", "./baidu.jpg");

//参数1: 网址
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 10 additions & 2 deletions zhtmltopdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ PHP_MINFO_FUNCTION(zhtmltopdf)
{
php_info_print_table_start();
php_info_print_table_header(2, "zhtmltopdf support", "enabled");
php_info_print_table_header(2, "wkhtmltopdf_version", wkhtmltopdf_version());
php_info_print_table_header(2, "version", "0.2");
php_info_print_table_header(2, "Author", "[email protected]");
php_info_print_table_end();

Expand Down Expand Up @@ -224,11 +224,13 @@ PHP_FUNCTION(zhtml2img)
char *url = NULL;
char *fmt = NULL;
char *out = NULL;
long quality = 80;
int url_len, fmt_len, out_len;

long len;
const unsigned char * data;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ss", &url, &url_len, &out, &out_len, &fmt, &fmt_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ssl", &url, &url_len, &out, &out_len, &fmt, &fmt_len, &quality) == FAILURE) {
return;
}

Expand All @@ -254,6 +256,12 @@ PHP_FUNCTION(zhtml2img)
wkhtmltoimage_set_global_setting(gs, "out", out);
}

if(quality < 1) {
quality = 80;
}

wkhtmltoimage_set_global_setting(gs, "quality", out);

c = wkhtmltoimage_create_converter(gs, NULL);

if (!wkhtmltoimage_convert(c)) {
Expand Down

0 comments on commit cdd1113

Please sign in to comment.