Skip to content

Commit a39dca1

Browse files
committed
ext/gd: imageclone support.
1 parent 7b2ca07 commit a39dca1

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

ext/gd/config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ AC_DEFUN([PHP_GD_CHECK_VERSION],[
198198
PHP_CHECK_LIBRARY(gd, gdFontCacheShutdown, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
199199
PHP_CHECK_LIBRARY(gd, gdVersionString, [AC_DEFINE(HAVE_GD_LIBVERSION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
200200
PHP_CHECK_LIBRARY(gd, gdImageGetInterpolationMethod, [AC_DEFINE(HAVE_GD_GET_INTERPOLATION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
201+
PHP_CHECK_LIBRARY(gd, gdImageClone, [AC_DEFINE(HAVE_GD_IMAGECLONE, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
201202
])
202203

203204
dnl

ext/gd/gd.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,3 +4169,26 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
41694169
}
41704170

41714171
/* }}} */
4172+
4173+
#if defined(HAVE_GD_IMAGECLONE)
4174+
PHP_FUNCTION(imageclone)
4175+
{
4176+
zval *IM;
4177+
gdImagePtr im;
4178+
gdImagePtr new;
4179+
4180+
ZEND_PARSE_PARAMETERS_START(1, 1)
4181+
Z_PARAM_OBJECT_OF_CLASS(IM, gd_image_ce)
4182+
ZEND_PARSE_PARAMETERS_END();
4183+
4184+
im = php_gd_libgdimageptr_from_zval_p(IM);
4185+
/* TODO adding the implementation in the bundled part ? */
4186+
new = gdImageClone(im);
4187+
4188+
if (!new) {
4189+
RETURN_FALSE;
4190+
}
4191+
4192+
php_gd_assign_libgdimageptr_as_extgdimage(return_value, new);
4193+
}
4194+
#endif

ext/gd/gd.stub.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,7 @@ function imagesetinterpolation(GdImage $image, int $method = IMG_BILINEAR_FIXED)
794794
* @refcount 1
795795
*/
796796
function imageresolution(GdImage $image, ?int $resolution_x = null, ?int $resolution_y = null): array|bool {}
797+
798+
#ifdef HAVE_GD_IMAGECLONE
799+
function imageclone(GdImage $image): GdImage|false {}
800+
#endif

ext/gd/gd_arginfo.h

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)