From: Pierre Joye Date: Sat, 8 Oct 2005 19:29:04 +0000 (+0000) Subject: - add compression mode argument to imagepng X-Git-Tag: RELEASE_0_9_1~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8b5fb88cd8b222ae946e7d93540e2fb0f0bf195;p=php - add compression mode argument to imagepng (MFH to 5.1?) --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 361076dc4c..76fb2347d2 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1851,12 +1851,12 @@ PHP_FUNCTION(imagegif) #endif /* HAVE_GD_GIF_CREATE */ #ifdef HAVE_GD_PNG -/* {{{ proto bool imagepng(resource im [, string filename]) +/* {{{ proto bool imagepng(resource im [, string filename [, int quality]]) Output PNG image to browser or file */ PHP_FUNCTION(imagepng) { #ifdef USE_GD_IOCTX - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "PNG", gdImagePngCtx); + _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 diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index 99cf87a170..c315b870ea 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -80,7 +80,6 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, q = Z_LVAL_PP(quality);/* or colorindex for foreground of BW images (defaults to black) */ } } - if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) { if (!fn || php_check_open_basedir(fn TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(fn, "rb+", CHECKUID_CHECK_FILE_AND_DIR))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename '%s'", fn); @@ -117,6 +116,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q); } case PHP_GDIMG_TYPE_JPG: + case PHP_GDIMG_TYPE_PNG: (*func_p)(im, ctx, q); break; case PHP_GDIMG_TYPE_XBM: