diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 7da5b8cd1b2ec..a95ea3fba70ec 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -233,7 +233,6 @@ if test "$PHP_GD" != "no"; then libgd/gd_io.c libgd/gd_jpeg.c libgd/gd_matrix.c - libgd/gd_pixelate.c libgd/gd_png.c libgd/gd_rotate.c libgd/gd_security.c diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 4e168fc3474f6..b410db7f1cb37 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -57,7 +57,7 @@ if (PHP_GD != "no") { gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \ gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \ gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \ - gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \ + gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \ gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); AC_DEFINE('HAVE_GD_BUNDLED', 1, "Define to 1 if gd extension uses GD library bundled in PHP."); AC_DEFINE('HAVE_GD_PNG', 1, "Define to 1 if gd extension has PNG support."); diff --git a/ext/gd/libgd/gd_filter.c b/ext/gd/libgd/gd_filter.c index db364c923ec60..d567898548d2e 100644 --- a/ext/gd/libgd/gd_filter.c +++ b/ext/gd/libgd/gd_filter.c @@ -110,6 +110,62 @@ int gdImageScatterEx(gdImagePtr im, gdScatterPtr scatter) return 1; } +int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode) +{ + int x, y; + + if (block_size <= 0) { + return 0; + } else if (block_size == 1) { + return 1; + } + switch (mode) { + case GD_PIXELATE_UPPERLEFT: + for (y = 0; y < im->sy; y += block_size) { + for (x = 0; x < im->sx; x += block_size) { + if (gdImageBoundsSafe(im, x, y)) { + int c = gdImageGetPixel(im, x, y); + gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c); + } + } + } + break; + case GD_PIXELATE_AVERAGE: + for (y = 0; y < im->sy; y += block_size) { + for (x = 0; x < im->sx; x += block_size) { + int a, r, g, b, c; + int total; + int cx, cy; + + a = r = g = b = c = total = 0; + /* sampling */ + for (cy = 0; cy < block_size; cy++) { + for (cx = 0; cx < block_size; cx++) { + if (!gdImageBoundsSafe(im, x + cx, y + cy)) { + continue; + } + c = gdImageGetPixel(im, x + cx, y + cy); + a += gdImageAlpha(im, c); + r += gdImageRed(im, c); + g += gdImageGreen(im, c); + b += gdImageBlue(im, c); + total++; + } + } + /* drawing */ + if (total > 0) { + c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total); + gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c); + } + } + } + break; + default: + return 0; + } + return 1; +} + /* invert src image */ int gdImageNegate(gdImagePtr src) { diff --git a/ext/gd/libgd/gd_pixelate.c b/ext/gd/libgd/gd_pixelate.c deleted file mode 100644 index 3808a6e55d91b..0000000000000 --- a/ext/gd/libgd/gd_pixelate.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "gd.h" - -int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode) -{ - int x, y; - - if (block_size <= 0) { - return 0; - } else if (block_size == 1) { - return 1; - } - switch (mode) { - case GD_PIXELATE_UPPERLEFT: - for (y = 0; y < im->sy; y += block_size) { - for (x = 0; x < im->sx; x += block_size) { - if (gdImageBoundsSafe(im, x, y)) { - int c = gdImageGetPixel(im, x, y); - gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c); - } - } - } - break; - case GD_PIXELATE_AVERAGE: - for (y = 0; y < im->sy; y += block_size) { - for (x = 0; x < im->sx; x += block_size) { - int a, r, g, b, c; - int total; - int cx, cy; - - a = r = g = b = c = total = 0; - /* sampling */ - for (cy = 0; cy < block_size; cy++) { - for (cx = 0; cx < block_size; cx++) { - if (!gdImageBoundsSafe(im, x + cx, y + cy)) { - continue; - } - c = gdImageGetPixel(im, x + cx, y + cy); - a += gdImageAlpha(im, c); - r += gdImageRed(im, c); - g += gdImageGreen(im, c); - b += gdImageBlue(im, c); - total++; - } - } - /* drawing */ - if (total > 0) { - c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total); - gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c); - } - } - } - break; - default: - return 0; - } - return 1; -}