|
version 1.1.1.1, 2012/02/21 23:47:56
|
version 1.1.1.2, 2012/05/29 12:34:39
|
|
Line 351 ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefrompng, 0)
|
Line 351 ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefrompng, 0)
|
| ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
| #endif |
#endif |
| |
|
| |
#ifdef HAVE_GD_WEBP |
| |
ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromwebp, 0) |
| |
ZEND_ARG_INFO(0, filename) |
| |
ZEND_END_ARG_INFO() |
| |
#endif |
| |
|
| #ifdef HAVE_GD_XBM |
#ifdef HAVE_GD_XBM |
| ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromxbm, 0) |
ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromxbm, 0) |
| ZEND_ARG_INFO(0, filename) |
ZEND_ARG_INFO(0, filename) |
|
Line 409 ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepng, 0, 0, 1)
|
Line 415 ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepng, 0, 0, 1)
|
| ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
| #endif |
#endif |
| |
|
| |
#ifdef HAVE_GD_WEBP |
| |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagewebp, 0, 0, 1) |
| |
ZEND_ARG_INFO(0, im) |
| |
ZEND_ARG_INFO(0, filename) |
| |
ZEND_END_ARG_INFO() |
| |
#endif |
| |
|
| #ifdef HAVE_GD_JPG |
#ifdef HAVE_GD_JPG |
| ZEND_BEGIN_ARG_INFO_EX(arginfo_imagejpeg, 0, 0, 1) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagejpeg, 0, 0, 1) |
| ZEND_ARG_INFO(0, im) |
ZEND_ARG_INFO(0, im) |
|
Line 498 ZEND_BEGIN_ARG_INFO(arginfo_imagecolorexact, 0)
|
Line 511 ZEND_BEGIN_ARG_INFO(arginfo_imagecolorexact, 0)
|
| ZEND_ARG_INFO(0, blue) |
ZEND_ARG_INFO(0, blue) |
| ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
| |
|
| ZEND_BEGIN_ARG_INFO(arginfo_imagecolorset, 0) | ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorset, 0, 0, 5) |
| ZEND_ARG_INFO(0, im) |
ZEND_ARG_INFO(0, im) |
| ZEND_ARG_INFO(0, color) |
ZEND_ARG_INFO(0, color) |
| ZEND_ARG_INFO(0, red) |
ZEND_ARG_INFO(0, red) |
| ZEND_ARG_INFO(0, green) |
ZEND_ARG_INFO(0, green) |
| ZEND_ARG_INFO(0, blue) |
ZEND_ARG_INFO(0, blue) |
| |
ZEND_ARG_INFO(0, alpha) |
| ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
| |
|
| ZEND_BEGIN_ARG_INFO(arginfo_imagecolorsforindex, 0) |
ZEND_BEGIN_ARG_INFO(arginfo_imagecolorsforindex, 0) |
|
Line 945 const zend_function_entry gd_functions[] = {
|
Line 959 const zend_function_entry gd_functions[] = {
|
| #ifdef HAVE_GD_PNG |
#ifdef HAVE_GD_PNG |
| PHP_FE(imagecreatefrompng, arginfo_imagecreatefrompng) |
PHP_FE(imagecreatefrompng, arginfo_imagecreatefrompng) |
| #endif |
#endif |
| |
#ifdef HAVE_GD_WEBP |
| |
PHP_FE(imagecreatefromwebp, arginfo_imagecreatefromwebp) |
| |
#endif |
| #ifdef HAVE_GD_GIF_READ |
#ifdef HAVE_GD_GIF_READ |
| PHP_FE(imagecreatefromgif, arginfo_imagecreatefromgif) |
PHP_FE(imagecreatefromgif, arginfo_imagecreatefromgif) |
| #endif |
#endif |
|
Line 968 const zend_function_entry gd_functions[] = {
|
Line 985 const zend_function_entry gd_functions[] = {
|
| #ifdef HAVE_GD_PNG |
#ifdef HAVE_GD_PNG |
| PHP_FE(imagepng, arginfo_imagepng) |
PHP_FE(imagepng, arginfo_imagepng) |
| #endif |
#endif |
| |
#ifdef HAVE_GD_WEBP |
| |
PHP_FE(imagewebp, arginfo_imagewebp) |
| |
#endif |
| #ifdef HAVE_GD_GIF_CREATE |
#ifdef HAVE_GD_GIF_CREATE |
| PHP_FE(imagegif, arginfo_imagegif) |
PHP_FE(imagegif, arginfo_imagegif) |
| #endif |
#endif |
|
Line 1470 PHP_FUNCTION(imageloadfont)
|
Line 1490 PHP_FUNCTION(imageloadfont)
|
| return; |
return; |
| } |
} |
| |
|
| stream = php_stream_open_wrapper(file, "rb", ENFORCE_SAFE_MODE | IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); | stream = php_stream_open_wrapper(file, "rb", IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); |
| if (stream == NULL) { |
if (stream == NULL) { |
| RETURN_FALSE; |
RETURN_FALSE; |
| } |
} |
|
Line 1559 PHP_FUNCTION(imageloadfont)
|
Line 1579 PHP_FUNCTION(imageloadfont)
|
| * that overlap with the old fonts (with indices 1-5). The first |
* that overlap with the old fonts (with indices 1-5). The first |
| * list index given out is always 1. |
* list index given out is always 1. |
| */ |
*/ |
| ind = 5 + zend_list_insert(font, le_gd_font); | ind = 5 + zend_list_insert(font, le_gd_font TSRMLS_CC); |
| |
|
| RETURN_LONG(ind); |
RETURN_LONG(ind); |
| } |
} |
|
Line 2422 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
Line 2442 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
| } |
} |
| } |
} |
| |
|
| stream = php_stream_open_wrapper(file, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); | stream = php_stream_open_wrapper(file, "rb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); |
| if (stream == NULL) { |
if (stream == NULL) { |
| RETURN_FALSE; |
RETURN_FALSE; |
| } |
} |
|
Line 2431 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
Line 2451 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
| ioctx_func_p = NULL; /* don't allow sockets without IOCtx */ |
ioctx_func_p = NULL; /* don't allow sockets without IOCtx */ |
| #endif |
#endif |
| |
|
| |
if (image_type == PHP_GDIMG_TYPE_WEBP) { |
| |
size_t buff_size; |
| |
char *buff; |
| |
|
| |
/* needs to be malloc (persistent) - GD will free() it later */ |
| |
buff_size = php_stream_copy_to_mem(stream, &buff, PHP_STREAM_COPY_ALL, 1); |
| |
if (!buff_size) { |
| |
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot read image data"); |
| |
goto out_err; |
| |
} |
| |
im = (*ioctx_func_p)(buff_size, buff); |
| |
if (!im) { |
| |
goto out_err; |
| |
} |
| |
goto register_im; |
| |
} |
| |
|
| /* try and avoid allocating a FILE* if the stream is not naturally a FILE* */ |
/* try and avoid allocating a FILE* if the stream is not naturally a FILE* */ |
| if (php_stream_is(stream, PHP_STREAM_IS_STDIO)) { |
if (php_stream_is(stream, PHP_STREAM_IS_STDIO)) { |
| if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS)) { |
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS)) { |
|
Line 2508 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
Line 2545 static void _php_image_create_from(INTERNAL_FUNCTION_P
|
| fflush(fp); |
fflush(fp); |
| } |
} |
| |
|
| |
register_im: |
| if (im) { |
if (im) { |
| ZEND_REGISTER_RESOURCE(return_value, im, le_gd); |
ZEND_REGISTER_RESOURCE(return_value, im, le_gd); |
| php_stream_close(stream); |
php_stream_close(stream); |
|
Line 2552 PHP_FUNCTION(imagecreatefrompng)
|
Line 2590 PHP_FUNCTION(imagecreatefrompng)
|
| /* }}} */ |
/* }}} */ |
| #endif /* HAVE_GD_PNG */ |
#endif /* HAVE_GD_PNG */ |
| |
|
| |
#ifdef HAVE_GD_WEBP |
| |
/* {{{ proto resource imagecreatefrompng(string filename) |
| |
Create a new image from PNG file or URL */ |
| |
PHP_FUNCTION(imagecreatefromwebp) |
| |
{ |
| |
_php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WEBP, "WEBP", gdImageCreateFromWebpPtr, gdImageCreateFromWebpPtr); |
| |
} |
| |
/* }}} */ |
| |
#endif /* HAVE_GD_VPX */ |
| |
|
| #ifdef HAVE_GD_XBM |
#ifdef HAVE_GD_XBM |
| /* {{{ proto resource imagecreatefromxbm(string filename) |
/* {{{ proto resource imagecreatefromxbm(string filename) |
| Create a new image from XBM file or URL */ |
Create a new image from XBM file or URL */ |
|
Line 2625 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
Line 2673 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
| /* When called from imagewbmp() the quality parameter stands for the foreground color. Default: black. */ |
/* When called from imagewbmp() the quality parameter stands for the foreground color. Default: black. */ |
| /* The quality parameter for gd2 stands for chunk size */ |
/* The quality parameter for gd2 stands for chunk size */ |
| |
|
| if (zend_parse_parameters(argc TSRMLS_CC, "r|sll", &imgind, &file, &file_len, &quality, &type) == FAILURE) { | if (zend_parse_parameters(argc TSRMLS_CC, "r|pll", &imgind, &file, &file_len, &quality, &type) == FAILURE) { |
| return; |
return; |
| } |
} |
| |
|
|
Line 2642 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
Line 2690 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
| } |
} |
| |
|
| if (argc >= 2 && file_len) { |
if (argc >= 2 && file_len) { |
| if (strlen(file) != file_len) { |
|
| RETURN_FALSE; |
|
| } |
|
| PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename"); |
PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename"); |
| |
|
| fp = VCWD_FOPEN(fn, "wb"); |
fp = VCWD_FOPEN(fn, "wb"); |
|
Line 2776 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
Line 2821 static void _php_image_output(INTERNAL_FUNCTION_PARAME
|
| #if HAVE_GD_BUNDLED |
#if HAVE_GD_BUNDLED |
| PHP_FUNCTION(imagexbm) |
PHP_FUNCTION(imagexbm) |
| { |
{ |
| _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XBM, "XBM", gdImageXbmCtx); | _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XBM, "GIF", gdImageXbmCtx); |
| } |
} |
| #endif |
#endif |
| /* }}} */ |
/* }}} */ |
|
Line 2786 PHP_FUNCTION(imagexbm)
|
Line 2831 PHP_FUNCTION(imagexbm)
|
| Output GIF image to browser or file */ |
Output GIF image to browser or file */ |
| PHP_FUNCTION(imagegif) |
PHP_FUNCTION(imagegif) |
| { |
{ |
| #ifdef HAVE_GD_GIF_CTX |
|
| _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GIF, "GIF", gdImageGifCtx); |
_php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GIF, "GIF", gdImageGifCtx); |
| #else |
|
| _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GIF, "GIF", gdImageGif); |
|
| #endif |
|
| } |
} |
| /* }}} */ |
/* }}} */ |
| #endif /* HAVE_GD_GIF_CREATE */ |
#endif /* HAVE_GD_GIF_CREATE */ |
|
Line 2800 PHP_FUNCTION(imagegif)
|
Line 2841 PHP_FUNCTION(imagegif)
|
| Output PNG image to browser or file */ |
Output PNG image to browser or file */ |
| PHP_FUNCTION(imagepng) |
PHP_FUNCTION(imagepng) |
| { |
{ |
| #ifdef USE_GD_IOCTX | _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "GIF", gdImagePngCtxEx); |
| _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "PNG", gdImagePngCtxEx); | |
| #else | |
| _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "PNG", gdImagePng); | |
| #endif | |
| } |
} |
| /* }}} */ |
/* }}} */ |
| #endif /* HAVE_GD_PNG */ |
#endif /* HAVE_GD_PNG */ |
| |
|
| |
|
| |
#ifdef HAVE_GD_WEBP |
| |
/* {{{ proto bool imagewebp(resource im [, string filename[, quality]] ) |
| |
Output PNG image to browser or file */ |
| |
PHP_FUNCTION(imagewebp) |
| |
{ |
| |
_php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WEBP, "GIF", gdImageWebpCtx); |
| |
} |
| |
/* }}} */ |
| |
#endif /* HAVE_GD_WEBP */ |
| |
|
| |
|
| #ifdef HAVE_GD_JPG |
#ifdef HAVE_GD_JPG |
| /* {{{ proto bool imagejpeg(resource im [, string filename [, int quality]]) |
/* {{{ proto bool imagejpeg(resource im [, string filename [, int quality]]) |
| Output JPEG image to browser or file */ |
Output JPEG image to browser or file */ |
| PHP_FUNCTION(imagejpeg) |
PHP_FUNCTION(imagejpeg) |
| { |
{ |
| #ifdef USE_GD_IOCTX | _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_JPG, "GIF", gdImageJpegCtx); |
| _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_JPG, "JPEG", gdImageJpegCtx); | |
| #else | |
| _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_JPG, "JPEG", gdImageJpeg); | |
| #endif | |
| } |
} |
| /* }}} */ |
/* }}} */ |
| #endif /* HAVE_GD_JPG */ |
#endif /* HAVE_GD_JPG */ |
|
Line 2828 PHP_FUNCTION(imagejpeg)
|
Line 2873 PHP_FUNCTION(imagejpeg)
|
| Output WBMP image to browser or file */ |
Output WBMP image to browser or file */ |
| PHP_FUNCTION(imagewbmp) |
PHP_FUNCTION(imagewbmp) |
| { |
{ |
| #ifdef USE_GD_IOCTX | _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "GIF", gdImageWBMPCtx); |
| _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "WBMP", gdImageWBMPCtx); | |
| #else | |
| _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "WBMP", gdImageWBMP); | |
| #endif | |
| } |
} |
| /* }}} */ |
/* }}} */ |
| #endif /* HAVE_GD_WBMP */ |
#endif /* HAVE_GD_WBMP */ |
|
Line 3061 PHP_FUNCTION(imagecolorexact)
|
Line 3102 PHP_FUNCTION(imagecolorexact)
|
| PHP_FUNCTION(imagecolorset) |
PHP_FUNCTION(imagecolorset) |
| { |
{ |
| zval *IM; |
zval *IM; |
| long color, red, green, blue; | long color, red, green, blue, alpha = 0; |
| int col; |
int col; |
| gdImagePtr im; |
gdImagePtr im; |
| |
|
| if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &color, &red, &green, &blue) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll|l", &IM, &color, &red, &green, &blue, &alpha) == FAILURE) { |
| return; |
return; |
| } |
} |
| |
|
|
Line 3077 PHP_FUNCTION(imagecolorset)
|
Line 3118 PHP_FUNCTION(imagecolorset)
|
| im->red[col] = red; |
im->red[col] = red; |
| im->green[col] = green; |
im->green[col] = green; |
| im->blue[col] = blue; |
im->blue[col] = blue; |
| |
im->alpha[col] = alpha; |
| } else { |
} else { |
| RETURN_FALSE; |
RETURN_FALSE; |
| } |
} |
|
Line 4096 PHP_FUNCTION(imagepscopyfont)
|
Line 4138 PHP_FUNCTION(imagepscopyfont)
|
| } |
} |
| |
|
| nf_ind->extend = 1; |
nf_ind->extend = 1; |
| l_ind = zend_list_insert(nf_ind, le_ps_font); | l_ind = zend_list_insert(nf_ind, le_ps_font TSRMLS_CC); |
| RETURN_LONG(l_ind); |
RETURN_LONG(l_ind); |
| } |
} |
| */ |
*/ |
|
Line 4145 PHP_FUNCTION(imagepsencodefont)
|
Line 4187 PHP_FUNCTION(imagepsencodefont)
|
| RETURN_FALSE; |
RETURN_FALSE; |
| } |
} |
| |
|
| zend_list_insert(enc_vector, le_ps_enc); | zend_list_insert(enc_vector, le_ps_enc TSRMLS_CC); |
| |
|
| RETURN_TRUE; |
RETURN_TRUE; |
| } |
} |
|
Line 4550 static void _php_image_convert(INTERNAL_FUNCTION_PARAM
|
Line 4592 static void _php_image_convert(INTERNAL_FUNCTION_PARAM
|
| long ignore_warning; |
long ignore_warning; |
| #endif |
#endif |
| |
|
| if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sslll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pplll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) { |
| return; |
return; |
| } |
} |
| |
|
|
Line 4559 static void _php_image_convert(INTERNAL_FUNCTION_PARAM
|
Line 4601 static void _php_image_convert(INTERNAL_FUNCTION_PARAM
|
| dest_height = height; |
dest_height = height; |
| dest_width = width; |
dest_width = width; |
| int_threshold = threshold; |
int_threshold = threshold; |
| |
|
| if (strlen(f_org) != f_org_len) { |
|
| RETURN_FALSE; |
|
| } |
|
| |
|
| if (strlen(f_dest) != f_dest_len) { |
|
| RETURN_FALSE; |
|
| } |
|
| |
|
| /* Check threshold value */ |
/* Check threshold value */ |
| if (int_threshold < 0 || int_threshold > 8) { |
if (int_threshold < 0 || int_threshold > 8) { |